llvm/test/CodeGen/Mips/largeimm1.ll
Simon Dardis 659228b9db [mips] Optimize stack pointer adjustments.
Instead of always using addu to adjust the stack pointer when the
size out is of the range of an addiu instruction, use subu so that
a smaller constant can be generated.

This can give savings of ~3 instructions whenever a function has a
a stack frame whose size is out of range of an addiu instruction.

This change may break some naive stack unwinders.

Partially resolves PR/26291.

Thanks to David Chisnall for reporting the issue.

Reviewers: dsanders, vkalintiris

Differential Review: http://reviews.llvm.org/D21321


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272666 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-14 13:39:43 +00:00

20 lines
545 B
LLVM

; RUN: llc -march=mipsel -relocation-model=pic < %s | FileCheck %s
define void @f() nounwind {
entry:
%a1 = alloca [1073741824 x i8], align 1
%arrayidx = getelementptr inbounds [1073741824 x i8], [1073741824 x i8]* %a1, i32 0, i32 1048676
call void @f2(i8* %arrayidx) nounwind
ret void
; CHECK-LABEL: f:
; CHECK: lui $[[R0:[a-z0-9]+]], 16384
; CHECK: addiu $[[R1:[a-z0-9]+]], $[[R0]], 24
; CHECK: subu $sp, $sp, $[[R1]]
; CHECK: lui $[[R2:[a-z0-9]+]], 16384
; CHECK: addu ${{[0-9]+}}, $sp, $[[R2]]
}
declare void @f2(i8*)