[PATCH] D65143: [InstCombine] Fold '(-1 u/ %x) u< %y' to '@llvm.umul.with.overflow' + overflow bit extraction

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 27 13:01:11 PDT 2019


nikic accepted this revision.
nikic added a comment.
This revision is now accepted and ready to land.

LGTM



================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:3349
+    if (I.getOperand(1) != Y)
+      Pred = I.getSwappedPredicate();
+
----------------
Side note: This seems pretty awkward and potentially bug prone. Having looked through the relatively few uses of this matcher, most cases either don't care (because they handle equalities) or would benefit from returning the swapped predicate. I think we should change the semantics to remove this potential footgun...


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:3370
+  if (NeedNegation)
+    Res = Builder.CreateNot(Res, "umul.not.ov");
+
----------------
Technically increases instruction count, but that seems justified here, especially as not's will usually be folded.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65143





More information about the llvm-commits mailing list