[PATCH] D125264: [ConstraintElimination] Simplify ssub(a, b) if a s>=b && a s>=0.

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 11 09:55:26 PDT 2022


spatel added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/ConstraintElimination.cpp:537-538
+  if (II->getIntrinsicID() == Intrinsic::ssub_with_overflow) {
+    // If A s>= B && A s>= 0, ssub.with.overflow(a, b) should not overflow and
+    // can be simplified to a regular sub.
+    Value *A = II->getArgOperand(0);
----------------
This pre-condition is not correct - if A is 0 and B is SMIN for a given width, that overflows.

Double-check to make sure I got the right pattern, but we should have a test like this:
https://alive2.llvm.org/ce/z/t9G3TQ


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125264/new/

https://reviews.llvm.org/D125264



More information about the llvm-commits mailing list