From 40ccf16b92f20c3a21cef5e9a07285f4721cd545 Mon Sep 17 00:00:00 2001 From: Jingyue Wu Date: Thu, 18 Jun 2015 03:35:57 +0000 Subject: [PATCH] [NFC] more comments in SLSR git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239984 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/StraightLineStrengthReduce.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp b/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp index 8e5cf46263e..f32769c2411 100644 --- a/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp +++ b/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp @@ -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; -- 2.34.1