@@ -1127,7 +1127,7 @@ static Instruction *foldSelectCtlzToCttz(ICmpInst *ICI, Value *TrueVal,
1127
1127
// / into:
1128
1128
// / %0 = tail call i32 @llvm.cttz.i32(i32 %x, i1 false)
1129
1129
static Value *foldSelectCttzCtlz (ICmpInst *ICI, Value *TrueVal, Value *FalseVal,
1130
- InstCombiner::BuilderTy &Builder ) {
1130
+ InstCombinerImpl &IC ) {
1131
1131
ICmpInst::Predicate Pred = ICI->getPredicate ();
1132
1132
Value *CmpLHS = ICI->getOperand (0 );
1133
1133
Value *CmpRHS = ICI->getOperand (1 );
@@ -1169,6 +1169,9 @@ static Value *foldSelectCttzCtlz(ICmpInst *ICI, Value *TrueVal, Value *FalseVal,
1169
1169
// Explicitly clear the 'is_zero_poison' flag. It's always valid to go from
1170
1170
// true to false on this flag, so we can replace it for all users.
1171
1171
II->setArgOperand (1 , ConstantInt::getFalse (II->getContext ()));
1172
+ // A range annotation on the intrinsic may no longer be valid.
1173
+ II->dropPoisonGeneratingAnnotations ();
1174
+ IC.addToWorklist (II);
1172
1175
return SelectArg;
1173
1176
}
1174
1177
@@ -1921,7 +1924,7 @@ Instruction *InstCombinerImpl::foldSelectInstWithICmp(SelectInst &SI,
1921
1924
if (Value *V = foldSelectICmpLshrAshr (ICI, TrueVal, FalseVal, Builder))
1922
1925
return replaceInstUsesWith (SI, V);
1923
1926
1924
- if (Value *V = foldSelectCttzCtlz (ICI, TrueVal, FalseVal, Builder ))
1927
+ if (Value *V = foldSelectCttzCtlz (ICI, TrueVal, FalseVal, * this ))
1925
1928
return replaceInstUsesWith (SI, V);
1926
1929
1927
1930
if (Value *V = canonicalizeSaturatedSubtract (ICI, TrueVal, FalseVal, Builder))
0 commit comments