[PATCH] D47908: [InstSimplify] add nuw %x, -1 -> -1 fold.

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 8 08:17:26 PDT 2018


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

LGTM.



================
Comment at: lib/Analysis/InstructionSimplify.cpp:530
 /// If not, this returns null.
 static Value *SimplifyAddInst(Value *Op0, Value *Op1, bool isNSW, bool isNUW,
                               const SimplifyQuery &Q, unsigned MaxRecurse) {
----------------
Possible cosmetic cleanup since we're here:
isNSW -> IsNSW
isNUW -> IsNUW


================
Comment at: lib/Analysis/InstructionSimplify.cpp:569-572
+  // add nuw i8 %x, -1  ->  -1, because %x can only be 0.
+  if (isNUW && match(Op1, m_AllOnes()))
+    return Op1; // Which is -1.
+
----------------
Better to put this above the previous fold, so wrapping-based folds are next to each other?


Repository:
  rL LLVM

https://reviews.llvm.org/D47908





More information about the llvm-commits mailing list