KnownOne, Depth, UserI);
if (!NewVal) return false;
U = NewVal;
-
- // Shrinking a constant might cause a nsw/nuw violation to occur in
- // instructions which are themselves demanded.
- if (auto *UserOBO = dyn_cast<OverflowingBinaryOperator>(UserI)) {
- cast<BinaryOperator>(UserOBO)->setHasNoSignedWrap(false);
- cast<BinaryOperator>(UserOBO)->setHasNoUnsignedWrap(false);
- }
return true;
}
if (SimplifyDemandedBits(I->getOperandUse(0), DemandedFromOps,
LHSKnownZero, LHSKnownOne, Depth + 1) ||
SimplifyDemandedBits(I->getOperandUse(1), DemandedFromOps,
- LHSKnownZero, LHSKnownOne, Depth + 1))
+ LHSKnownZero, LHSKnownOne, Depth + 1)) {
+ cast<BinaryOperator>(I)->setHasNoSignedWrap(false);
+ cast<BinaryOperator>(I)->setHasNoUnsignedWrap(false);
return I;
+ }
}
}
break;
if (SimplifyDemandedBits(I->getOperandUse(0), DemandedFromOps,
LHSKnownZero, LHSKnownOne, Depth + 1) ||
SimplifyDemandedBits(I->getOperandUse(1), DemandedFromOps,
- LHSKnownZero, LHSKnownOne, Depth + 1))
+ LHSKnownZero, LHSKnownOne, Depth + 1)) {
+ cast<BinaryOperator>(I)->setHasNoSignedWrap(false);
+ cast<BinaryOperator>(I)->setHasNoUnsignedWrap(false);
return I;
+ }
}
// Otherwise just hand the sub off to computeKnownBits to fill in
%trunc = trunc i32 %sub to i1
ret i1 %trunc
}
+
+define i1 @PR23309v2(i32 %A, i32 %B) {
+; CHECK-LABEL: @PR23309v2(
+; CHECK-NEXT: %[[sub:.*]] = add i32 %A, %B
+; CHECK-NEXT: %[[and:.*]] = and i32 %[[sub]], 1
+; CHECK-NEXT: %[[cmp:.*]] = icmp ne i32 %[[and]], 0
+; CHECK-NEXT: ret i1 %[[cmp]]
+ %add = add i32 %A, -4
+ %sub = add nuw i32 %add, %B
+ %trunc = trunc i32 %sub to i1
+ ret i1 %trunc
+}