[llvm] r239984 - [NFC] more comments in SLSR

Jingyue Wu jingyue at google.com
Wed Jun 17 20:35:58 PDT 2015


Author: jingyue
Date: Wed Jun 17 22:35:57 2015
New Revision: 239984

URL: http://llvm.org/viewvc/llvm-project?rev=239984&view=rev
Log:
[NFC] more comments in SLSR

Modified:
    llvm/trunk/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp?rev=239984&r1=239983&r2=239984&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp Wed Jun 17 22:35:57 2015
@@ -632,6 +632,15 @@ void StraightLineStrengthReduce::rewrite
       // trivially dead.
       RecursivelyDeleteTriviallyDeadInstructions(Bump);
     } else {
+      // It's tempting to preserve nsw on Bump and/or Reduced. However, it's
+      // usually unsound, e.g.,
+      //
+      // X = (-2 +nsw 1) *nsw INT_MAX
+      // Y = (-2 +nsw 3) *nsw INT_MAX
+      //   =>
+      // Y = X + 2 * INT_MAX
+      //
+      // Neither + and * in the resultant expression are nsw.
       Reduced = Builder.CreateAdd(Basis.Ins, Bump);
     }
     break;





More information about the llvm-commits mailing list