2012-08-02 20:15:13 +02:00
|
|
|
; RUN: llc -march=mipsel -pre-RA-sched=source < %s | FileCheck %s
|
2011-03-09 20:22:22 +01:00
|
|
|
|
|
|
|
; All test functions do the same thing - they return the first variable
|
|
|
|
; argument.
|
|
|
|
|
2011-04-13 02:38:32 +02: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-09 20:22:22 +01: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-27 22:17:42 +01:00
|
|
|
%tmp = load i32, i32* %b, align 4
|
2011-03-09 20:22:22 +01:00
|
|
|
ret i32 %tmp
|
|
|
|
|
2013-07-14 08:24:09 +02:00
|
|
|
; CHECK-LABEL: va1:
|
2012-07-25 05:16:47 +02:00
|
|
|
; CHECK: addiu $sp, $sp, -16
|
|
|
|
; CHECK: sw $7, 28($sp)
|
|
|
|
; CHECK: sw $6, 24($sp)
|
2017-03-03 11:02:25 +01:00
|
|
|
; CHECK: sw $5, 20($sp)
|
2012-07-25 05:16:47 +02:00
|
|
|
; CHECK: lw $2, 20($sp)
|
2011-03-09 20:22:22 +01:00
|
|
|
}
|
|
|
|
|
2011-04-13 02:38:32 +02: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-09 20:22:22 +01: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-27 22:17:42 +01:00
|
|
|
%tmp = load double, double* %b, align 8
|
2011-03-09 20:22:22 +01:00
|
|
|
ret double %tmp
|
|
|
|
|
2013-07-14 08:24:09 +02:00
|
|
|
; CHECK-LABEL: va2:
|
2012-07-25 05:16:47 +02: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-03-31 20:42:43 +02: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-09 20:22:22 +01: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-27 22:17:42 +01:00
|
|
|
%tmp = load i32, i32* %b, align 4
|
2011-03-09 20:22:22 +01:00
|
|
|
ret i32 %tmp
|
|
|
|
|
2013-07-14 08:24:09 +02:00
|
|
|
; CHECK-LABEL: va3:
|
2012-07-25 05:16:47 +02:00
|
|
|
; CHECK: addiu $sp, $sp, -16
|
In visitSTORE, always use FindBetterChain, rather than only when UseAA is enabled.
Recommiting after fixup of 32-bit aliasing sign offset bug in DAGCombiner.
* Simplify Consecutive Merge Store Candidate Search
Now that address aliasing is much less conservative, push through
simplified store merging search and chain alias analysis 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.
When 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 the output
Codegen (save perhaps for some ARM cases where we correctly constructs
wider loads, but then promotes them to float operations which appear
but requires more expensive constant generation).
Some minor peephole optimizations to deal with improved SubDAG shapes (listed below)
Additional Minor Changes:
1. Finishes removing unused AliasLoad code
2. Unifies 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 seems sufficient to not cause regressions in
tests.
5. Remove Chain dependencies of Memory operations on CopyfromReg
nodes as these are captured by data dependence
6. Forward loads-store values through tokenfactors containing
{CopyToReg,CopyFromReg} Values.
7. Peephole to convert buildvector of extract_vector_elt to
extract_subvector if possible (see
CodeGen/AArch64/store-merge.ll)
8. Store merging for the ARM target is restricted to 32-bit as
some in some contexts invalid 64-bit operations are being
generated. This can be removed once appropriate checks are
added.
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, improving load-store forwarding. One test in
particular is worth noting:
CodeGen/PowerPC/ppc64-align-long-double.ll - Improved load-store
forwarding converts a load-store pair into a parallel store and
a memory-realized bitcast of the same value. However, because we
lose the sharing of the explicit and implicit store values we
must create another local store. A similar transformation
happens before SelectionDAG as well.
Reviewers: arsenm, hfinkel, tstellarAMD, jyknight, nhaehnle
llvm-svn: 296476
2017-02-28 15:24:15 +01:00
|
|
|
; CHECK: sw $7, 28($sp)
|
2017-03-03 11:02:25 +01:00
|
|
|
; CHECK: sw $6, 24($sp)
|
2012-07-25 05:16:47 +02:00
|
|
|
; CHECK: lw $2, 24($sp)
|
2011-03-09 20:22:22 +01: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-27 22:17:42 +01:00
|
|
|
%tmp = load double, double* %b, align 8
|
2011-03-09 20:22:22 +01:00
|
|
|
ret double %tmp
|
|
|
|
|
2013-07-14 08:24:09 +02:00
|
|
|
; CHECK-LABEL: va4:
|
2012-07-25 05:16:47 +02: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-09 20:22:22 +01: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-27 22:17:42 +01:00
|
|
|
%tmp = load i32, i32* %d, align 4
|
2011-03-09 20:22:22 +01:00
|
|
|
ret i32 %tmp
|
|
|
|
|
2013-07-14 08:24:09 +02:00
|
|
|
; CHECK-LABEL: va5:
|
2012-07-25 05:16:47 +02:00
|
|
|
; CHECK: addiu $sp, $sp, -24
|
|
|
|
; CHECK: sw $7, 36($sp)
|
|
|
|
; CHECK: lw $2, 36($sp)
|
2011-03-09 20:22:22 +01: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-27 22:17:42 +01:00
|
|
|
%tmp = load double, double* %d, align 8
|
2011-03-09 20:22:22 +01:00
|
|
|
ret double %tmp
|
|
|
|
|
2013-07-14 08:24:09 +02:00
|
|
|
; CHECK-LABEL: va6:
|
2012-07-25 05:16:47 +02:00
|
|
|
; CHECK: addiu $sp, $sp, -24
|
|
|
|
; CHECK: sw $7, 36($sp)
|
|
|
|
; CHECK: addiu $[[R0:[0-9]+]], $sp, 36
|
2011-03-31 20:42:43 +02: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-09 20:22:22 +01: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-27 22:17:42 +01:00
|
|
|
%tmp = load i32, i32* %c, align 4
|
2011-03-09 20:22:22 +01:00
|
|
|
ret i32 %tmp
|
|
|
|
|
2013-07-14 08:24:09 +02:00
|
|
|
; CHECK-LABEL: va7:
|
2012-07-25 05:16:47 +02:00
|
|
|
; CHECK: addiu $sp, $sp, -24
|
|
|
|
; CHECK: lw $2, 40($sp)
|
2011-03-09 20:22:22 +01: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-27 22:17:42 +01:00
|
|
|
%tmp = load double, double* %c, align 8
|
2011-03-09 20:22:22 +01:00
|
|
|
ret double %tmp
|
|
|
|
|
2013-07-14 08:24:09 +02:00
|
|
|
; CHECK-LABEL: va8:
|
2012-07-25 05:16:47 +02:00
|
|
|
; CHECK: addiu $sp, $sp, -32
|
|
|
|
; CHECK: addiu ${{[0-9]+}}, $sp, 48
|
|
|
|
; CHECK: ldc1 $f0, 48($sp)
|
2011-03-09 20:22:22 +01: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-27 22:17:42 +01:00
|
|
|
%tmp = load i32, i32* %d, align 4
|
2011-03-09 20:22:22 +01:00
|
|
|
ret i32 %tmp
|
|
|
|
|
2013-07-14 08:24:09 +02:00
|
|
|
; CHECK-LABEL: va9:
|
Elide argument copies during instruction selection
Summary:
Avoids tons of prologue boilerplate when arguments are passed in memory
and left in memory. This can happen in a debug build or in a release
build when an argument alloca is escaped. This will dramatically affect
the code size of x86 debug builds, because X86 fast isel doesn't handle
arguments passed in memory at all. It only handles the x86_64 case of up
to 6 basic register parameters.
This is implemented by analyzing the entry block before ISel to identify
copy elision candidates. A copy elision candidate is an argument that is
used to fully initialize an alloca before any other possibly escaping
uses of that alloca. If an argument is a copy elision candidate, we set
a flag on the InputArg. If the the target generates loads from a fixed
stack object that matches the size and alignment requirements of the
alloca, the SelectionDAG builder will delete the stack object created
for the alloca and replace it with the fixed stack object. The load is
left behind to satisfy any remaining uses of the argument value. The
store is now dead and is therefore elided. The fixed stack object is
also marked as mutable, as it may now be modified by the user, and it
would be invalid to rematerialize the initial load from it.
Supersedes D28388
Fixes PR26328
Reviewers: chandlerc, MatzeB, qcolombet, inglorion, hans
Subscribers: igorb, llvm-commits
Differential Revision: https://reviews.llvm.org/D29668
llvm-svn: 296683
2017-03-01 22:42:00 +01:00
|
|
|
; CHECK: addiu $sp, $sp, -24
|
|
|
|
; CHECK: lw $2, 44($sp)
|
2011-03-09 20:22:22 +01: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-27 22:17:42 +01:00
|
|
|
%tmp = load double, double* %d, align 8
|
2011-03-09 20:22:22 +01:00
|
|
|
ret double %tmp
|
|
|
|
|
2013-07-14 08:24:09 +02:00
|
|
|
; CHECK-LABEL: va10:
|
2012-07-25 05:16:47 +02:00
|
|
|
; CHECK: addiu $sp, $sp, -32
|
|
|
|
; CHECK: addiu $[[R0:[0-9]+]], $sp, 52
|
2011-03-31 20:42:43 +02: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-09 20:22:22 +01:00
|
|
|
}
|