[NFC] more comments in SLSR
authorJingyue Wu <jingyue@google.com>
Thu, 18 Jun 2015 03:35:57 +0000 (03:35 +0000)
committerJingyue Wu <jingyue@google.com>
Thu, 18 Jun 2015 03:35:57 +0000 (03:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239984 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/StraightLineStrengthReduce.cpp

index 8e5cf46263ed822d3c5146f5e04357f39e37fd63..f32769c241101ab41eab5a77b02ef96cf9c34d15 100644 (file)
@@ -632,6 +632,15 @@ void StraightLineStrengthReduce::rewriteCandidateWithBasis(
       // 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;