2012-08-03 02:15:13 +08:00
|
|
|
; RUN: llc -march=mipsel -pre-RA-sched=source < %s | FileCheck %s
|
2011-03-10 03:22:22 +08:00
|
|
|
|
|
|
|
; All test functions do the same thing - they return the first variable
|
|
|
|
; argument.
|
|
|
|
|
2011-04-13 08:38:32 +08:00
|
|
|
; All CHECK's do the same thing - they check whether variable arguments from
|
|
|
|
; registers are placed on correct stack locations, and whether the first
|
2011-03-10 03:22:22 +08:00
|
|
|
; variable argument is returned from the correct stack location.
|
|
|
|
|
|
|
|
|
|
|
|
declare void @llvm.va_start(i8*) nounwind
|
|
|
|
declare void @llvm.va_end(i8*) nounwind
|
|
|
|
|
|
|
|
; return int
|
|
|
|
define i32 @va1(i32 %a, ...) nounwind {
|
|
|
|
entry:
|
|
|
|
%a.addr = alloca i32, align 4
|
|
|
|
%ap = alloca i8*, align 4
|
|
|
|
%b = alloca i32, align 4
|
|
|
|
store i32 %a, i32* %a.addr, align 4
|
|
|
|
%ap1 = bitcast i8** %ap to i8*
|
|
|
|
call void @llvm.va_start(i8* %ap1)
|
|
|
|
%0 = va_arg i8** %ap, i32
|
|
|
|
store i32 %0, i32* %b, align 4
|
|
|
|
%ap2 = bitcast i8** %ap to i8*
|
|
|
|
call void @llvm.va_end(i8* %ap2)
|
2015-02-28 05:17:42 +08:00
|
|
|
%tmp = load i32, i32* %b, align 4
|
2011-03-10 03:22:22 +08:00
|
|
|
ret i32 %tmp
|
|
|
|
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: va1:
|
2012-07-25 11:16:47 +08:00
|
|
|
; CHECK: addiu $sp, $sp, -16
|
In visitSTORE, always use FindBetterChain, rather than only when UseAA is enabled.
Retrying after upstream changes.
Simplify Consecutive Merge Store Candidate Search
Now that address aliasing is much less conservative, push through
simplified store merging search which only checks for parallel stores
through the chain subgraph. This is cleaner as the separation of
non-interfering loads/stores from the store-merging logic.
Whem merging stores, search up the chain through a single load, and
finds all possible stores by looking down from through a load and a
TokenFactor to all stores visited. This improves the quality of the
output SelectionDAG and generally the output CodeGen (with some
exceptions).
Additional Minor Changes:
1. Finishes removing unused AliasLoad code
2. Unifies the the chain aggregation in the merged stores across
code paths
3. Re-add the Store node to the worklist after calling
SimplifyDemandedBits.
4. Increase GatherAllAliasesMaxDepth from 6 to 18. That number is
arbitrary, but seemed sufficient to not cause regressions in
tests.
This finishes the change Matt Arsenault started in r246307 and
jyknight's original patch.
Many tests required some changes as memory operations are now
reorderable. Some tests relying on the order were changed to use
volatile memory operations
Noteworthy tests:
CodeGen/AArch64/argument-blocks.ll -
It's not entirely clear what the test_varargs_stackalign test is
supposed to be asserting, but the new code looks right.
CodeGen/AArch64/arm64-memset-inline.lli -
CodeGen/AArch64/arm64-stur.ll -
CodeGen/ARM/memset-inline.ll -
The backend now generates *worse* code due to store merging
succeeding, as we do do a 16-byte constant-zero store efficiently.
CodeGen/AArch64/merge-store.ll -
Improved, but there still seems to be an extraneous vector insert
from an element to itself?
CodeGen/PowerPC/ppc64-align-long-double.ll -
Worse code emitted in this case, due to the improved store->load
forwarding.
CodeGen/X86/dag-merge-fast-accesses.ll -
CodeGen/X86/MergeConsecutiveStores.ll -
CodeGen/X86/stores-merging.ll -
CodeGen/Mips/load-store-left-right.ll -
Restored correct merging of non-aligned stores
CodeGen/AMDGPU/promote-alloca-stored-pointer-value.ll -
Improved. Correctly merges buffer_store_dword calls
CodeGen/AMDGPU/si-triv-disjoint-mem-access.ll -
Improved. Sidesteps loading a stored value and
merges two stores
CodeGen/X86/pr18023.ll -
This test has been removed, as it was asserting incorrect
behavior. Non-volatile stores *CAN* be moved past volatile loads,
and now are.
CodeGen/X86/vector-idiv.ll -
CodeGen/X86/vector-lzcnt-128.ll -
It's basically impossible to tell what these tests are actually
testing. But, looks like the code got better due to the memory
operations being recognized as non-aliasing.
CodeGen/X86/win32-eh.ll -
Both loads of the securitycookie are now merged.
CodeGen/AMDGPU/vgpr-spill-emergency-stack-slot-compute.ll -
This test appears to work but no longer exhibits the spill behavior.
Reviewers: arsenm, hfinkel, tstellarAMD, jyknight, nhaehnle
Subscribers: wdng, nhaehnle, nemanjai, arsenm, weimingz, niravd, RKSimon, aemerson, qcolombet, dsanders, resistor, tstellarAMD, t.p.northover, spatel
Differential Revision: https://reviews.llvm.org/D14834
llvm-svn: 284151
2016-10-14 03:20:16 +08:00
|
|
|
; CHECK: sw $5, 20($sp)
|
2012-07-25 11:16:47 +08:00
|
|
|
; CHECK: sw $7, 28($sp)
|
|
|
|
; CHECK: sw $6, 24($sp)
|
|
|
|
; CHECK: lw $2, 20($sp)
|
2011-03-10 03:22:22 +08:00
|
|
|
}
|
|
|
|
|
2011-04-13 08:38:32 +08:00
|
|
|
; check whether the variable double argument will be accessed from the 8-byte
|
|
|
|
; aligned location (i.e. whether the address is computed by adding 7 and
|
2011-03-10 03:22:22 +08:00
|
|
|
; clearing lower 3 bits)
|
|
|
|
define double @va2(i32 %a, ...) nounwind {
|
|
|
|
entry:
|
|
|
|
%a.addr = alloca i32, align 4
|
|
|
|
%ap = alloca i8*, align 4
|
|
|
|
%b = alloca double, align 8
|
|
|
|
store i32 %a, i32* %a.addr, align 4
|
|
|
|
%ap1 = bitcast i8** %ap to i8*
|
|
|
|
call void @llvm.va_start(i8* %ap1)
|
|
|
|
%0 = va_arg i8** %ap, double
|
|
|
|
store double %0, double* %b, align 8
|
|
|
|
%ap2 = bitcast i8** %ap to i8*
|
|
|
|
call void @llvm.va_end(i8* %ap2)
|
2015-02-28 05:17:42 +08:00
|
|
|
%tmp = load double, double* %b, align 8
|
2011-03-10 03:22:22 +08:00
|
|
|
ret double %tmp
|
|
|
|
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: va2:
|
2012-07-25 11:16:47 +08:00
|
|
|
; CHECK: addiu $sp, $sp, -16
|
|
|
|
; CHECK: sw $7, 28($sp)
|
|
|
|
; CHECK: sw $6, 24($sp)
|
|
|
|
; CHECK: sw $5, 20($sp)
|
|
|
|
; CHECK: addiu $[[R0:[0-9]+]], $sp, 20
|
2011-04-01 02:42:43 +08:00
|
|
|
; CHECK: addiu $[[R1:[0-9]+]], $[[R0]], 7
|
|
|
|
; CHECK: addiu $[[R2:[0-9]+]], $zero, -8
|
|
|
|
; CHECK: and $[[R3:[0-9]+]], $[[R1]], $[[R2]]
|
|
|
|
; CHECK: ldc1 $f0, 0($[[R3]])
|
2011-03-10 03:22:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
; int
|
|
|
|
define i32 @va3(double %a, ...) nounwind {
|
|
|
|
entry:
|
|
|
|
%a.addr = alloca double, align 8
|
|
|
|
%ap = alloca i8*, align 4
|
|
|
|
%b = alloca i32, align 4
|
|
|
|
store double %a, double* %a.addr, align 8
|
|
|
|
%ap1 = bitcast i8** %ap to i8*
|
|
|
|
call void @llvm.va_start(i8* %ap1)
|
|
|
|
%0 = va_arg i8** %ap, i32
|
|
|
|
store i32 %0, i32* %b, align 4
|
|
|
|
%ap2 = bitcast i8** %ap to i8*
|
|
|
|
call void @llvm.va_end(i8* %ap2)
|
2015-02-28 05:17:42 +08:00
|
|
|
%tmp = load i32, i32* %b, align 4
|
2011-03-10 03:22:22 +08:00
|
|
|
ret i32 %tmp
|
|
|
|
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: va3:
|
2012-07-25 11:16:47 +08:00
|
|
|
; CHECK: addiu $sp, $sp, -16
|
2016-09-29 00:37:50 +08:00
|
|
|
; CHECK: sw $6, 24($sp)
|
In visitSTORE, always use FindBetterChain, rather than only when UseAA is enabled.
Retrying after upstream changes.
Simplify Consecutive Merge Store Candidate Search
Now that address aliasing is much less conservative, push through
simplified store merging search which only checks for parallel stores
through the chain subgraph. This is cleaner as the separation of
non-interfering loads/stores from the store-merging logic.
Whem merging stores, search up the chain through a single load, and
finds all possible stores by looking down from through a load and a
TokenFactor to all stores visited. This improves the quality of the
output SelectionDAG and generally the output CodeGen (with some
exceptions).
Additional Minor Changes:
1. Finishes removing unused AliasLoad code
2. Unifies the the chain aggregation in the merged stores across
code paths
3. Re-add the Store node to the worklist after calling
SimplifyDemandedBits.
4. Increase GatherAllAliasesMaxDepth from 6 to 18. That number is
arbitrary, but seemed sufficient to not cause regressions in
tests.
This finishes the change Matt Arsenault started in r246307 and
jyknight's original patch.
Many tests required some changes as memory operations are now
reorderable. Some tests relying on the order were changed to use
volatile memory operations
Noteworthy tests:
CodeGen/AArch64/argument-blocks.ll -
It's not entirely clear what the test_varargs_stackalign test is
supposed to be asserting, but the new code looks right.
CodeGen/AArch64/arm64-memset-inline.lli -
CodeGen/AArch64/arm64-stur.ll -
CodeGen/ARM/memset-inline.ll -
The backend now generates *worse* code due to store merging
succeeding, as we do do a 16-byte constant-zero store efficiently.
CodeGen/AArch64/merge-store.ll -
Improved, but there still seems to be an extraneous vector insert
from an element to itself?
CodeGen/PowerPC/ppc64-align-long-double.ll -
Worse code emitted in this case, due to the improved store->load
forwarding.
CodeGen/X86/dag-merge-fast-accesses.ll -
CodeGen/X86/MergeConsecutiveStores.ll -
CodeGen/X86/stores-merging.ll -
CodeGen/Mips/load-store-left-right.ll -
Restored correct merging of non-aligned stores
CodeGen/AMDGPU/promote-alloca-stored-pointer-value.ll -
Improved. Correctly merges buffer_store_dword calls
CodeGen/AMDGPU/si-triv-disjoint-mem-access.ll -
Improved. Sidesteps loading a stored value and
merges two stores
CodeGen/X86/pr18023.ll -
This test has been removed, as it was asserting incorrect
behavior. Non-volatile stores *CAN* be moved past volatile loads,
and now are.
CodeGen/X86/vector-idiv.ll -
CodeGen/X86/vector-lzcnt-128.ll -
It's basically impossible to tell what these tests are actually
testing. But, looks like the code got better due to the memory
operations being recognized as non-aliasing.
CodeGen/X86/win32-eh.ll -
Both loads of the securitycookie are now merged.
CodeGen/AMDGPU/vgpr-spill-emergency-stack-slot-compute.ll -
This test appears to work but no longer exhibits the spill behavior.
Reviewers: arsenm, hfinkel, tstellarAMD, jyknight, nhaehnle
Subscribers: wdng, nhaehnle, nemanjai, arsenm, weimingz, niravd, RKSimon, aemerson, qcolombet, dsanders, resistor, tstellarAMD, t.p.northover, spatel
Differential Revision: https://reviews.llvm.org/D14834
llvm-svn: 284151
2016-10-14 03:20:16 +08:00
|
|
|
; CHECK: sw $7, 28($sp)
|
2012-07-25 11:16:47 +08:00
|
|
|
; CHECK: lw $2, 24($sp)
|
2011-03-10 03:22:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
; double
|
|
|
|
define double @va4(double %a, ...) nounwind {
|
|
|
|
entry:
|
|
|
|
%a.addr = alloca double, align 8
|
|
|
|
%ap = alloca i8*, align 4
|
|
|
|
%b = alloca double, align 8
|
|
|
|
store double %a, double* %a.addr, align 8
|
|
|
|
%ap1 = bitcast i8** %ap to i8*
|
|
|
|
call void @llvm.va_start(i8* %ap1)
|
|
|
|
%0 = va_arg i8** %ap, double
|
|
|
|
store double %0, double* %b, align 8
|
|
|
|
%ap2 = bitcast i8** %ap to i8*
|
|
|
|
call void @llvm.va_end(i8* %ap2)
|
2015-02-28 05:17:42 +08:00
|
|
|
%tmp = load double, double* %b, align 8
|
2011-03-10 03:22:22 +08:00
|
|
|
ret double %tmp
|
|
|
|
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: va4:
|
2012-07-25 11:16:47 +08:00
|
|
|
; CHECK: addiu $sp, $sp, -24
|
|
|
|
; CHECK: sw $7, 36($sp)
|
|
|
|
; CHECK: sw $6, 32($sp)
|
|
|
|
; CHECK: addiu ${{[0-9]+}}, $sp, 32
|
|
|
|
; CHECK: ldc1 $f0, 32($sp)
|
2011-03-10 03:22:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
; int
|
|
|
|
define i32 @va5(i32 %a, i32 %b, i32 %c, ...) nounwind {
|
|
|
|
entry:
|
|
|
|
%a.addr = alloca i32, align 4
|
|
|
|
%b.addr = alloca i32, align 4
|
|
|
|
%c.addr = alloca i32, align 4
|
|
|
|
%ap = alloca i8*, align 4
|
|
|
|
%d = alloca i32, align 4
|
|
|
|
store i32 %a, i32* %a.addr, align 4
|
|
|
|
store i32 %b, i32* %b.addr, align 4
|
|
|
|
store i32 %c, i32* %c.addr, align 4
|
|
|
|
%ap1 = bitcast i8** %ap to i8*
|
|
|
|
call void @llvm.va_start(i8* %ap1)
|
|
|
|
%0 = va_arg i8** %ap, i32
|
|
|
|
store i32 %0, i32* %d, align 4
|
|
|
|
%ap2 = bitcast i8** %ap to i8*
|
|
|
|
call void @llvm.va_end(i8* %ap2)
|
2015-02-28 05:17:42 +08:00
|
|
|
%tmp = load i32, i32* %d, align 4
|
2011-03-10 03:22:22 +08:00
|
|
|
ret i32 %tmp
|
|
|
|
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: va5:
|
2012-07-25 11:16:47 +08:00
|
|
|
; CHECK: addiu $sp, $sp, -24
|
|
|
|
; CHECK: sw $7, 36($sp)
|
|
|
|
; CHECK: lw $2, 36($sp)
|
2011-03-10 03:22:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
; double
|
|
|
|
define double @va6(i32 %a, i32 %b, i32 %c, ...) nounwind {
|
|
|
|
entry:
|
|
|
|
%a.addr = alloca i32, align 4
|
|
|
|
%b.addr = alloca i32, align 4
|
|
|
|
%c.addr = alloca i32, align 4
|
|
|
|
%ap = alloca i8*, align 4
|
|
|
|
%d = alloca double, align 8
|
|
|
|
store i32 %a, i32* %a.addr, align 4
|
|
|
|
store i32 %b, i32* %b.addr, align 4
|
|
|
|
store i32 %c, i32* %c.addr, align 4
|
|
|
|
%ap1 = bitcast i8** %ap to i8*
|
|
|
|
call void @llvm.va_start(i8* %ap1)
|
|
|
|
%0 = va_arg i8** %ap, double
|
|
|
|
store double %0, double* %d, align 8
|
|
|
|
%ap2 = bitcast i8** %ap to i8*
|
|
|
|
call void @llvm.va_end(i8* %ap2)
|
2015-02-28 05:17:42 +08:00
|
|
|
%tmp = load double, double* %d, align 8
|
2011-03-10 03:22:22 +08:00
|
|
|
ret double %tmp
|
|
|
|
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: va6:
|
2012-07-25 11:16:47 +08:00
|
|
|
; CHECK: addiu $sp, $sp, -24
|
|
|
|
; CHECK: sw $7, 36($sp)
|
|
|
|
; CHECK: addiu $[[R0:[0-9]+]], $sp, 36
|
2011-04-01 02:42:43 +08:00
|
|
|
; CHECK: addiu $[[R1:[0-9]+]], $[[R0]], 7
|
|
|
|
; CHECK: addiu $[[R2:[0-9]+]], $zero, -8
|
|
|
|
; CHECK: and $[[R3:[0-9]+]], $[[R1]], $[[R2]]
|
|
|
|
; CHECK: ldc1 $f0, 0($[[R3]])
|
2011-03-10 03:22:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
; int
|
|
|
|
define i32 @va7(i32 %a, double %b, ...) nounwind {
|
|
|
|
entry:
|
|
|
|
%a.addr = alloca i32, align 4
|
|
|
|
%b.addr = alloca double, align 8
|
|
|
|
%ap = alloca i8*, align 4
|
|
|
|
%c = alloca i32, align 4
|
|
|
|
store i32 %a, i32* %a.addr, align 4
|
|
|
|
store double %b, double* %b.addr, align 8
|
|
|
|
%ap1 = bitcast i8** %ap to i8*
|
|
|
|
call void @llvm.va_start(i8* %ap1)
|
|
|
|
%0 = va_arg i8** %ap, i32
|
|
|
|
store i32 %0, i32* %c, align 4
|
|
|
|
%ap2 = bitcast i8** %ap to i8*
|
|
|
|
call void @llvm.va_end(i8* %ap2)
|
2015-02-28 05:17:42 +08:00
|
|
|
%tmp = load i32, i32* %c, align 4
|
2011-03-10 03:22:22 +08:00
|
|
|
ret i32 %tmp
|
|
|
|
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: va7:
|
2012-07-25 11:16:47 +08:00
|
|
|
; CHECK: addiu $sp, $sp, -24
|
|
|
|
; CHECK: lw $2, 40($sp)
|
2011-03-10 03:22:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
; double
|
|
|
|
define double @va8(i32 %a, double %b, ...) nounwind {
|
|
|
|
entry:
|
|
|
|
%a.addr = alloca i32, align 4
|
|
|
|
%b.addr = alloca double, align 8
|
|
|
|
%ap = alloca i8*, align 4
|
|
|
|
%c = alloca double, align 8
|
|
|
|
store i32 %a, i32* %a.addr, align 4
|
|
|
|
store double %b, double* %b.addr, align 8
|
|
|
|
%ap1 = bitcast i8** %ap to i8*
|
|
|
|
call void @llvm.va_start(i8* %ap1)
|
|
|
|
%0 = va_arg i8** %ap, double
|
|
|
|
store double %0, double* %c, align 8
|
|
|
|
%ap2 = bitcast i8** %ap to i8*
|
|
|
|
call void @llvm.va_end(i8* %ap2)
|
2015-02-28 05:17:42 +08:00
|
|
|
%tmp = load double, double* %c, align 8
|
2011-03-10 03:22:22 +08:00
|
|
|
ret double %tmp
|
|
|
|
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: va8:
|
2012-07-25 11:16:47 +08:00
|
|
|
; CHECK: addiu $sp, $sp, -32
|
|
|
|
; CHECK: addiu ${{[0-9]+}}, $sp, 48
|
|
|
|
; CHECK: ldc1 $f0, 48($sp)
|
2011-03-10 03:22:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
; int
|
|
|
|
define i32 @va9(double %a, double %b, i32 %c, ...) nounwind {
|
|
|
|
entry:
|
|
|
|
%a.addr = alloca double, align 8
|
|
|
|
%b.addr = alloca double, align 8
|
|
|
|
%c.addr = alloca i32, align 4
|
|
|
|
%ap = alloca i8*, align 4
|
|
|
|
%d = alloca i32, align 4
|
|
|
|
store double %a, double* %a.addr, align 8
|
|
|
|
store double %b, double* %b.addr, align 8
|
|
|
|
store i32 %c, i32* %c.addr, align 4
|
|
|
|
%ap1 = bitcast i8** %ap to i8*
|
|
|
|
call void @llvm.va_start(i8* %ap1)
|
|
|
|
%0 = va_arg i8** %ap, i32
|
|
|
|
store i32 %0, i32* %d, align 4
|
|
|
|
%ap2 = bitcast i8** %ap to i8*
|
|
|
|
call void @llvm.va_end(i8* %ap2)
|
2015-02-28 05:17:42 +08:00
|
|
|
%tmp = load i32, i32* %d, align 4
|
2011-03-10 03:22:22 +08:00
|
|
|
ret i32 %tmp
|
|
|
|
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: va9:
|
2012-07-25 11:16:47 +08:00
|
|
|
; CHECK: addiu $sp, $sp, -32
|
|
|
|
; CHECK: lw $2, 52($sp)
|
2011-03-10 03:22:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
; double
|
|
|
|
define double @va10(double %a, double %b, i32 %c, ...) nounwind {
|
|
|
|
entry:
|
|
|
|
%a.addr = alloca double, align 8
|
|
|
|
%b.addr = alloca double, align 8
|
|
|
|
%c.addr = alloca i32, align 4
|
|
|
|
%ap = alloca i8*, align 4
|
|
|
|
%d = alloca double, align 8
|
|
|
|
store double %a, double* %a.addr, align 8
|
|
|
|
store double %b, double* %b.addr, align 8
|
|
|
|
store i32 %c, i32* %c.addr, align 4
|
|
|
|
%ap1 = bitcast i8** %ap to i8*
|
|
|
|
call void @llvm.va_start(i8* %ap1)
|
|
|
|
%0 = va_arg i8** %ap, double
|
|
|
|
store double %0, double* %d, align 8
|
|
|
|
%ap2 = bitcast i8** %ap to i8*
|
|
|
|
call void @llvm.va_end(i8* %ap2)
|
2015-02-28 05:17:42 +08:00
|
|
|
%tmp = load double, double* %d, align 8
|
2011-03-10 03:22:22 +08:00
|
|
|
ret double %tmp
|
|
|
|
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: va10:
|
2012-07-25 11:16:47 +08:00
|
|
|
; CHECK: addiu $sp, $sp, -32
|
|
|
|
; CHECK: addiu $[[R0:[0-9]+]], $sp, 52
|
2011-04-01 02:42:43 +08:00
|
|
|
; CHECK: addiu $[[R1:[0-9]+]], $[[R0]], 7
|
|
|
|
; CHECK: addiu $[[R2:[0-9]+]], $zero, -8
|
|
|
|
; CHECK: and $[[R3:[0-9]+]], $[[R1]], $[[R2]]
|
|
|
|
; CHECK: ldc1 $f0, 0($[[R3]])
|
2011-03-10 03:22:22 +08:00
|
|
|
}
|