2016-03-31 07:38:01 +08:00
|
|
|
; RUN: llc %s -o - -enable-shrink-wrap=true -no-x86-call-frame-opt | FileCheck %s --check-prefix=CHECK --check-prefix=ENABLE
|
|
|
|
; RUN: llc %s -o - -enable-shrink-wrap=false -no-x86-call-frame-opt | FileCheck %s --check-prefix=CHECK --check-prefix=DISABLE
|
2015-12-02 09:22:54 +08:00
|
|
|
target datalayout = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128"
|
2016-06-29 22:51:10 +08:00
|
|
|
target triple = "i386-apple-macosx10.5"
|
2015-12-02 09:22:54 +08:00
|
|
|
|
|
|
|
@a = common global i32 0, align 4
|
|
|
|
@d = internal unnamed_addr global i1 false
|
|
|
|
@b = common global i32 0, align 4
|
|
|
|
@e = common global i8 0, align 1
|
|
|
|
@f = common global i8 0, align 1
|
|
|
|
@c = common global i32 0, align 4
|
|
|
|
@.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
|
|
|
|
|
|
|
|
|
|
|
|
; Check that we are clobbering the flags when they are live-in of the
|
|
|
|
; prologue block and the prologue needs to adjust the stack.
|
|
|
|
; PR25607.
|
|
|
|
;
|
|
|
|
; CHECK-LABEL: eflagsLiveInPrologue:
|
|
|
|
;
|
|
|
|
; DISABLE: pushl
|
|
|
|
; DISABLE-NEXT: pushl
|
|
|
|
; DISABLE-NEXT: subl $20, %esp
|
|
|
|
;
|
|
|
|
; CHECK: movl L_a$non_lazy_ptr, [[A:%[a-z]+]]
|
|
|
|
; CHECK-NEXT: cmpl $0, ([[A]])
|
|
|
|
; CHECK-NEXT: je [[PREHEADER_LABEL:LBB[0-9_]+]]
|
|
|
|
;
|
|
|
|
; CHECK: movb $1, _d
|
|
|
|
;
|
|
|
|
; CHECK: [[PREHEADER_LABEL]]:
|
|
|
|
; CHECK-NEXT: movl L_b$non_lazy_ptr, [[B:%[a-z]+]]
|
|
|
|
; CHECK-NEXT: movl ([[B]]), [[TMP1:%[a-z]+]]
|
|
|
|
; CHECK-NEXT: testl [[TMP1]], [[TMP1]]
|
|
|
|
; CHECK-NEXT: je [[FOREND_LABEL:LBB[0-9_]+]]
|
|
|
|
;
|
|
|
|
; Skip the loop.
|
|
|
|
; [...]
|
|
|
|
;
|
|
|
|
; The for.end block is split to accomadate the different selects.
|
|
|
|
; We are interested in the one with the call, so skip until the branch.
|
|
|
|
; CHECK: [[FOREND_LABEL]]:
|
2018-02-12 10:48:42 +08:00
|
|
|
; CHECK-NEXT: xorl
|
|
|
|
; CHECK-NEXT: cmpb $0, _d
|
|
|
|
; CHECK-NEXT: movl $0, %edx
|
|
|
|
; CHECK-NEXT: jne [[CALL_LABEL:LBB[0-9_]+]]
|
2015-12-02 09:22:54 +08:00
|
|
|
;
|
2018-02-12 10:48:42 +08:00
|
|
|
; CHECK: movb $6, %dl
|
2015-12-02 09:22:54 +08:00
|
|
|
;
|
|
|
|
; CHECK: [[CALL_LABEL]]
|
|
|
|
;
|
|
|
|
; ENABLE-NEXT: pushl
|
|
|
|
; ENABLE-NEXT: pushl
|
|
|
|
; We must not use sub here otherwise we will clobber the eflags.
|
|
|
|
; ENABLE-NEXT: leal -20(%esp), %esp
|
|
|
|
;
|
|
|
|
; CHECK-NEXT: L_e$non_lazy_ptr, [[E:%[a-z]+]]
|
2018-02-12 10:48:42 +08:00
|
|
|
; CHECK-NEXT: movb %dl, ([[E]])
|
In visitSTORE, always use FindBetterChain, rather than only when UseAA is enabled.
Recommiting with compiler time improvements
Recommitting 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: 297695
2017-03-14 08:34:14 +08:00
|
|
|
; CHECK-NEXT: movsbl ([[E]]), [[CONV:%[a-z]+]]
|
2015-12-02 09:22:54 +08:00
|
|
|
; CHECK-NEXT: movl $6, [[CONV:%[a-z]+]]
|
|
|
|
; The eflags is used in the next instruction.
|
|
|
|
; If that instruction disappear, we are not exercising the bug
|
|
|
|
; anymore.
|
|
|
|
; CHECK-NEXT: cmovnel {{%[a-z]+}}, [[CONV]]
|
|
|
|
;
|
|
|
|
; Skip all the crust of vaarg lowering.
|
2016-06-29 22:51:10 +08:00
|
|
|
; CHECK: calll _varfunc
|
2015-12-02 09:22:54 +08:00
|
|
|
; Set the return value to 0.
|
|
|
|
; CHECK-NEXT: xorl %eax, %eax
|
|
|
|
; CHECK-NEXT: addl $20, %esp
|
|
|
|
; CHECK-NEXT: popl
|
|
|
|
; CHECK-NEXT: popl
|
|
|
|
; CHECK-NEXT: retl
|
|
|
|
define i32 @eflagsLiveInPrologue() #0 {
|
|
|
|
entry:
|
|
|
|
%tmp = load i32, i32* @a, align 4
|
|
|
|
%tobool = icmp eq i32 %tmp, 0
|
|
|
|
br i1 %tobool, label %for.cond.preheader, label %if.then
|
|
|
|
|
|
|
|
if.then: ; preds = %entry
|
|
|
|
store i1 true, i1* @d, align 1
|
|
|
|
br label %for.cond.preheader
|
|
|
|
|
|
|
|
for.cond.preheader: ; preds = %if.then, %entry
|
|
|
|
%tmp1 = load i32, i32* @b, align 4
|
|
|
|
%tobool14 = icmp eq i32 %tmp1, 0
|
|
|
|
br i1 %tobool14, label %for.end, label %for.body.preheader
|
|
|
|
|
|
|
|
for.body.preheader: ; preds = %for.cond.preheader
|
|
|
|
br label %for.body
|
|
|
|
|
|
|
|
for.body: ; preds = %for.body, %for.body.preheader
|
|
|
|
br label %for.body
|
|
|
|
|
|
|
|
for.end: ; preds = %for.cond.preheader
|
|
|
|
%.b3 = load i1, i1* @d, align 1
|
|
|
|
%tmp2 = select i1 %.b3, i8 0, i8 6
|
|
|
|
store i8 %tmp2, i8* @e, align 1
|
In visitSTORE, always use FindBetterChain, rather than only when UseAA is enabled.
Recommiting with compiler time improvements
Recommitting 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: 297695
2017-03-14 08:34:14 +08:00
|
|
|
%tmp3 = load i8, i8* @e, align 1
|
2015-12-02 09:22:54 +08:00
|
|
|
%conv = sext i8 %tmp3 to i32
|
|
|
|
%add = add nsw i32 %conv, 1
|
|
|
|
%rem = srem i32 %tmp1, %add
|
|
|
|
store i32 %rem, i32* @c, align 4
|
|
|
|
%conv2 = select i1 %.b3, i32 0, i32 6
|
|
|
|
%call = tail call i32 (i8*, ...) @varfunc(i8* nonnull getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 %conv2) #1
|
|
|
|
ret i32 0
|
|
|
|
}
|
|
|
|
|
|
|
|
; Function Attrs: nounwind
|
|
|
|
declare i32 @varfunc(i8* nocapture readonly, ...) #0
|
|
|
|
|
|
|
|
attributes #0 = { nounwind "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-features"="+mmx,+sse" "unsafe-fp-math"="false" "use-soft-float"="false" }
|
|
|
|
attributes #1 = { nounwind }
|