summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/GuardUtils.cpp
diff options
context:
space:
mode:
authorPhilip Reames <listmail@philipreames.com>2019-04-02 16:51:43 +0000
committerPhilip Reames <listmail@philipreames.com>2019-04-02 16:51:43 +0000
commitd3d5d76a7b7e8c0cfcb21a37b2fd9b4b2a67a0b8 (patch)
tree26d6a995d3d23d9b9f35a36316cd4e1d687c83d7 /llvm/lib/Analysis/GuardUtils.cpp
parent017deaf1ae3aa84211a416a37e2c895a18c2a5e3 (diff)
downloadbcm5719-llvm-d3d5d76a7b7e8c0cfcb21a37b2fd9b4b2a67a0b8.tar.gz
bcm5719-llvm-d3d5d76a7b7e8c0cfcb21a37b2fd9b4b2a67a0b8.zip
[WideableCond] Fix a nasty bug in detection of "explicit guards"
The code was failing to actually check for the presence of the call to widenable_condition. The whole point of specifying the widenable_condition intrinsic was allowing widening transforms. A normal branch is not widenable. A normal branch leading to a deopt is not widenable (in general). I added a test case via LoopPredication, but GuardWidening has an analogous bug. Those are the only two passes actually using this utility just yet. Noticed while working on LoopPredication for non-widenable branches; POC in D60111. llvm-svn: 357493
Diffstat (limited to 'llvm/lib/Analysis/GuardUtils.cpp')
-rw-r--r--llvm/lib/Analysis/GuardUtils.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/GuardUtils.cpp b/llvm/lib/Analysis/GuardUtils.cpp
index c099ee8e41c..cad92f6e56b 100644
--- a/llvm/lib/Analysis/GuardUtils.cpp
+++ b/llvm/lib/Analysis/GuardUtils.cpp
@@ -39,6 +39,11 @@ bool llvm::parseWidenableBranch(const User *U, Value *&Condition,
Value *&WidenableCondition,
BasicBlock *&IfTrueBB, BasicBlock *&IfFalseBB) {
using namespace llvm::PatternMatch;
- return match(U, m_Br(m_And(m_Value(Condition), m_Value(WidenableCondition)),
- IfTrueBB, IfFalseBB));
+ if (!match(U, m_Br(m_And(m_Value(Condition), m_Value(WidenableCondition)),
+ IfTrueBB, IfFalseBB)))
+ return false;
+ // TODO: At the moment, we only recognize the branch if the WC call in this
+ // specific position. We should generalize!
+ return match(WidenableCondition,
+ m_Intrinsic<Intrinsic::experimental_widenable_condition>());
}
OpenPOWER on IntegriCloud