@@ -8268,8 +8268,10 @@ static bool optimizeBranch(BranchInst *Branch, const TargetLowering &TLI,
8268
8268
if (CmpC.isPowerOf2 () && Cmp->getPredicate () == ICmpInst::ICMP_ULT &&
8269
8269
match (UI, m_Shr (m_Specific (X), m_SpecificInt (CmpC.logBase2 ())))) {
8270
8270
IRBuilder<> Builder (Branch);
8271
- if (UI->getParent () != Branch->getParent ())
8271
+ if (UI->getParent () != Branch->getParent ()) {
8272
8272
UI->moveBefore (Branch);
8273
+ UI->dropPoisonGeneratingFlags ();
8274
+ }
8273
8275
Value *NewCmp = Builder.CreateCmp (ICmpInst::ICMP_EQ, UI,
8274
8276
ConstantInt::get (UI->getType (), 0 ));
8275
8277
LLVM_DEBUG (dbgs () << " Converting " << *Cmp << " \n " );
@@ -8281,8 +8283,10 @@ static bool optimizeBranch(BranchInst *Branch, const TargetLowering &TLI,
8281
8283
(match (UI, m_Add (m_Specific (X), m_SpecificInt (-CmpC))) ||
8282
8284
match (UI, m_Sub (m_Specific (X), m_SpecificInt (CmpC))))) {
8283
8285
IRBuilder<> Builder (Branch);
8284
- if (UI->getParent () != Branch->getParent ())
8286
+ if (UI->getParent () != Branch->getParent ()) {
8285
8287
UI->moveBefore (Branch);
8288
+ UI->dropPoisonGeneratingFlags ();
8289
+ }
8286
8290
Value *NewCmp = Builder.CreateCmp (Cmp->getPredicate (), UI,
8287
8291
ConstantInt::get (UI->getType (), 0 ));
8288
8292
LLVM_DEBUG (dbgs () << " Converting " << *Cmp << " \n " );
0 commit comments