[llvm] [InstCombine] Simplify `(X / C0) * C1 + (X % C0) * C2` to `(X / C0) * (C1 - C2 * C0) + X * C2` (PR #76285)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 23 05:36:50 PST 2023


================
@@ -3872,6 +3872,10 @@ Instruction *InstCombinerImpl::visitOr(BinaryOperator &I) {
     }
   }
 
+  if (cast<PossiblyDisjointInst>(I).isDisjoint())
----------------
dtcxzyw wrote:

It is ugly. But I don't know the best approach to treat `or disjoint` as `add nsw nuw`.

It is a phase ordering issue. We cannot assume that `ReassociatePass` will revert the canonicalization `add -> or disjoint`. BTW, I see this change achieves higher coverage in my benchmark (in `openexr/ImfTimeCode.cpp` and `z3/mpf.cpp`).


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


More information about the llvm-commits mailing list