[llvm] [InstCombine] Simplify fractions when there is no overflow (PR #92949)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 27 05:54:43 PDT 2024
================
@@ -1176,6 +1176,45 @@ Instruction *InstCombinerImpl::commonIDivTransforms(BinaryOperator &I) {
Mul->setHasNoSignedWrap(OBO->hasNoSignedWrap());
return Mul;
}
+
+ // We can reduce expressions of things like * 150 / 100 to * 3 / 2
+ if (Op0->hasOneUse() && !C2->isZero() &&
+ !(IsSigned && C1->isMinSignedValue() && C2->isAllOnes())) {
+ assert(!C2->isMinSignedValue() &&
+ "This should have been folded away by InstSimplify");
----------------
goldsteinn wrote:
Not InstSimplify, InstCombine. It will get folded, but this shouldn't be an assert as we sometimes move around folds. Just check it in the above if statement.
https://github.com/llvm/llvm-project/pull/92949
More information about the llvm-commits
mailing list