diff options
author | Jacques Pienaar <jpienaar@google.com> | 2016-04-05 16:18:13 +0000 |
---|---|---|
committer | Jacques Pienaar <jpienaar@google.com> | 2016-04-05 16:18:13 +0000 |
commit | 42991b3e5ad397a82e2f0336f608a3f911dfbdc7 (patch) | |
tree | fd6ca842d01bee433a80e5d499fc9ad11ca0afc5 | |
parent | ed89fae6c547fb5d1568ec66cb446f9ba2792e2a (diff) | |
download | bcm5719-llvm-42991b3e5ad397a82e2f0336f608a3f911dfbdc7.tar.gz bcm5719-llvm-42991b3e5ad397a82e2f0336f608a3f911dfbdc7.zip |
[lanai] LanaiSetflagAluCombiner more conservative
Summary: LanaiSetflagAluCombiner could previously combine instructions across basic building blocks even when not legal. Make the LanaiSetflagAluCombiner more conservative to avoid this.
Reviewers: eliben
Subscribers: joker.eph, llvm-commits
Differential Revision: http://reviews.llvm.org/D18746
llvm-svn: 265411
-rw-r--r-- | llvm/lib/Target/Lanai/LanaiSetflagAluCombiner.cpp | 12 | ||||
-rw-r--r-- | llvm/test/CodeGen/Lanai/combined_alu_setcc.ll | 50 |
2 files changed, 54 insertions, 8 deletions
diff --git a/llvm/lib/Target/Lanai/LanaiSetflagAluCombiner.cpp b/llvm/lib/Target/Lanai/LanaiSetflagAluCombiner.cpp index 28a13909711..988352b0150 100644 --- a/llvm/lib/Target/Lanai/LanaiSetflagAluCombiner.cpp +++ b/llvm/lib/Target/Lanai/LanaiSetflagAluCombiner.cpp @@ -233,20 +233,22 @@ static bool isSuitableSetflag(MbbIterator Instruction, MbbIterator End) { MbbIterator SCCUserIter = Instruction; while (SCCUserIter != End) { ++SCCUserIter; - // Early exit when encountering flag setting instruction. - if (isFlagSettingInstruction(SCCUserIter->getOpcode())) - break; + // Early exit when encountering flag setting or return instruction. + if (isFlagSettingInstruction(SCCUserIter->getOpcode()) || + SCCUserIter->isReturn()) + // Only return true if flags are set post the flag setting instruction + // tested or a return is executed. + return true; int CCIndex = getCCOperandPosition(SCCUserIter->getOpcode()); if (CCIndex != -1) { LPCC::CondCode CC = static_cast<LPCC::CondCode>( SCCUserIter->getOperand(CCIndex).getImm()); + // Return false if the flag is used outside of a EQ, NE, PL and MI. if (CC != LPCC::ICC_EQ && CC != LPCC::ICC_NE && CC != LPCC::ICC_PL && CC != LPCC::ICC_MI) return false; } } - - return true; } return false; diff --git a/llvm/test/CodeGen/Lanai/combined_alu_setcc.ll b/llvm/test/CodeGen/Lanai/combined_alu_setcc.ll index 5f035b20fa1..a94012584d3 100644 --- a/llvm/test/CodeGen/Lanai/combined_alu_setcc.ll +++ b/llvm/test/CodeGen/Lanai/combined_alu_setcc.ll @@ -121,6 +121,50 @@ return: ; preds = %if.end6, %if.end, % ret i32 %retval.0 } ; CHECK-LABEL: test4 -; CHECK: and.f -; CHECK: and.f -; CHECK: and.f +; TODO: Re-enable test. This test is disabled post making the combiner more +; conservative. +; DISABLED_CHECK: and.f + +; Test to avoid incorrect fusing that spans across basic blocks +@a = global i32 -1, align 4 +@b = global i32 0, align 4 + +; Function Attrs: nounwind +define void @testBB() { +entry: + %0 = load i32, i32* @a, align 4, !tbaa !1 + %1 = load i32, i32* @b, align 4, !tbaa !1 + %sub.i = sub i32 %1, %0 + %tobool = icmp sgt i32 %sub.i, -1 + br i1 %tobool, label %if.end, label %if.then + +if.then: ; preds = %entry + %call1 = tail call i32 bitcast (i32 (...)* @g to i32 ()*)() + br label %while.body + +while.body: ; preds = %if.then, %while.body + br label %while.body + +if.end: ; preds = %entry + %cmp.i = icmp slt i32 %sub.i, 1 + br i1 %cmp.i, label %if.then4, label %if.end7 + +if.then4: ; preds = %if.end + %call5 = tail call i32 bitcast (i32 (...)* @g to i32 ()*)() + br label %while.body6 + +while.body6: ; preds = %if.then4, %while.body6 + br label %while.body6 + +if.end7: ; preds = %if.end + ret void +} + +declare i32 @g(...) +; CHECK-LABEL: testBB +; CHECK: sub.f {{.*}}, %r0 + +!1 = !{!2, !2, i64 0} +!2 = !{!"int", !3, i64 0} +!3 = !{!"omnipotent char", !4, i64 0} +!4 = !{!"Simple C/C++ TBAA"} |