[PATCH] D52709: Add -instcombine-code-sinking option
Gabor Buella via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 25 01:34:43 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL345248: Add -instcombine-code-sinking option (authored by GBuella, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D52709?vs=170164&id=171049#toc
Repository:
rL LLVM
https://reviews.llvm.org/D52709
Files:
llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/trunk/test/Transforms/InstCombine/no_sink_instruction.ll
Index: llvm/trunk/test/Transforms/InstCombine/no_sink_instruction.ll
===================================================================
--- llvm/trunk/test/Transforms/InstCombine/no_sink_instruction.ll
+++ llvm/trunk/test/Transforms/InstCombine/no_sink_instruction.ll
@@ -0,0 +1,19 @@
+; RUN: opt -instcombine -instcombine-code-sinking=0 -S < %s | FileCheck %s
+
+define i32 @test(i1 %C, i32 %A, i32 %B) {
+; CHECK-LABEL: @test(
+; CHECK: sdiv i32
+; CHECK-NEXT: add i32
+entry:
+ %tmp.2 = sdiv i32 %A, %B ; <i32> [#uses=1]
+ %tmp.9 = add i32 %B, %A ; <i32> [#uses=1]
+ br i1 %C, label %then, label %endif
+
+then: ; preds = %entry
+; CHECK: ret i32
+ ret i32 %tmp.9
+
+endif: ; preds = %entry
+; CHECK: ret i32
+ ret i32 %tmp.2
+}
Index: llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
===================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -120,6 +120,10 @@
"Controls which instructions are visited");
static cl::opt<bool>
+EnableCodeSinking("instcombine-code-sinking", cl::desc("Enable code sinking"),
+ cl::init(true));
+
+static cl::opt<bool>
EnableExpensiveCombines("expensive-combines",
cl::desc("Enable expensive instruction combines"));
@@ -3103,7 +3107,7 @@
}
// See if we can trivially sink this instruction to a successor basic block.
- if (I->hasOneUse()) {
+ if (EnableCodeSinking && I->hasOneUse()) {
BasicBlock *BB = I->getParent();
Instruction *UserInst = cast<Instruction>(*I->user_begin());
BasicBlock *UserParent;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52709.171049.patch
Type: text/x-patch
Size: 1807 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181025/3d045717/attachment.bin>
More information about the llvm-commits
mailing list