[llvm] [InstCombine] Simplification for (-a * b) / (a * b). (PR #71768)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 13 05:53:40 PST 2023


================
@@ -1230,6 +1230,10 @@ static Value *simplifySDivInst(Value *Op0, Value *Op1, bool IsExact,
   // If two operands are negated and no signed overflow, return -1.
   if (isKnownNegation(Op0, Op1, /*NeedNSW=*/true))
     return Constant::getAllOnesValue(Op0->getType());
+  Value *X, *Y;
----------------
dtcxzyw wrote:

Clang failed to fold `(-a + b) / (a - b)` into `-1` due to the lack of `nsw` flag.
Alive2: https://alive2.llvm.org/ce/z/tPAt3K

You can create a separate patch to address this :)


https://github.com/llvm/llvm-project/pull/71768


More information about the llvm-commits mailing list