[PATCH] D64285: [InstSimplify] Fold select (icmp sgt x, -1), lshr (X, Y), ashr (X, Y) to ashr (X, Y))

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 9 08:48:27 PDT 2019


lebedev.ri requested changes to this revision.
lebedev.ri added a comment.
This revision now requires changes to proceed.

Thank you for working on this!



================
Comment at: lib/Analysis/InstructionSimplify.cpp:82-85
+  if ((Pred == ICmpInst::ICMP_SGT && match(CmpRHS, m_AllOnes())) ||
+      (Pred == ICmpInst::ICMP_SLT && match(CmpRHS, m_One()))) {
+    if (Pred == ICmpInst::ICMP_SLT)
+      std::swap(TrueVal, FalseVal);
----------------
There was some utility function to check for sign-bit tests, i think, i can't find it..


================
Comment at: lib/Analysis/InstructionSimplify.cpp:90-92
+      if (cast<BinaryOperator>(TrueVal)->isExact() !=
+          cast<BinaryOperator>(FalseVal)->isExact())
+        cast<BinaryOperator>(FalseVal)->setIsExact(false);
----------------
This modifies existing instruction.
I really don't think this is legal for instsimplify.

The mismatch case should stay in instcombine.


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

https://reviews.llvm.org/D64285





More information about the llvm-commits mailing list