[PATCH] D50247: [GuardWidening] Ignore guards with trivial conditions
Max Kazantsev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 21 19:41:39 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL340381: [GuardWidening] Ignore guards with trivial conditions (authored by mkazantsev, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D50247?vs=158986&id=161880#toc
Repository:
rL LLVM
https://reviews.llvm.org/D50247
Files:
llvm/trunk/lib/Transforms/Scalar/GuardWidening.cpp
llvm/trunk/test/Transforms/GuardWidening/basic.ll
Index: llvm/trunk/lib/Transforms/Scalar/GuardWidening.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Scalar/GuardWidening.cpp
+++ llvm/trunk/lib/Transforms/Scalar/GuardWidening.cpp
@@ -347,6 +347,12 @@
Instruction *GuardInst, const df_iterator<DomTreeNode *> &DFSI,
const DenseMap<BasicBlock *, SmallVector<Instruction *, 8>> &
GuardsInBlock, bool InvertCondition) {
+ // Ignore trivial true or false conditions. These instructions will be
+ // trivially eliminated by any cleanup pass. Do not erase them because other
+ // guards can possibly be widened into them.
+ if (isa<ConstantInt>(getCondition(GuardInst)))
+ return false;
+
Instruction *BestSoFar = nullptr;
auto BestScoreSoFar = WS_IllegalOrNegative;
auto *GuardInstLoop = LI.getLoopFor(GuardInst->getParent());
Index: llvm/trunk/test/Transforms/GuardWidening/basic.ll
===================================================================
--- llvm/trunk/test/Transforms/GuardWidening/basic.ll
+++ llvm/trunk/test/Transforms/GuardWidening/basic.ll
@@ -379,3 +379,29 @@
right:
ret void
}
+
+; Make sure we do not widen guard by trivial true conditions into something.
+define void @f_15(i1 %cond_0, i1 %cond_1) {
+; CHECK-LABEL: @f_15(
+entry:
+; CHECK: call void (i1, ...) @llvm.experimental.guard(i1 %cond_0) [ "deopt"() ]
+; CHECK: call void (i1, ...) @llvm.experimental.guard(i1 true) [ "deopt"() ]
+; CHECK: ret void
+
+ call void(i1, ...) @llvm.experimental.guard(i1 %cond_0) [ "deopt"() ]
+ call void(i1, ...) @llvm.experimental.guard(i1 true) [ "deopt"() ]
+ ret void
+}
+
+; Make sure we do not widen guard by trivial false conditions into something.
+define void @f_16(i1 %cond_0, i1 %cond_1) {
+; CHECK-LABEL: @f_16(
+entry:
+; CHECK: call void (i1, ...) @llvm.experimental.guard(i1 %cond_0) [ "deopt"() ]
+; CHECK: call void (i1, ...) @llvm.experimental.guard(i1 false) [ "deopt"() ]
+; CHECK: ret void
+
+ call void(i1, ...) @llvm.experimental.guard(i1 %cond_0) [ "deopt"() ]
+ call void(i1, ...) @llvm.experimental.guard(i1 false) [ "deopt"() ]
+ ret void
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50247.161880.patch
Type: text/x-patch
Size: 2136 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180822/23cc6feb/attachment.bin>
More information about the llvm-commits
mailing list