[PATCH] D35256: [SCEV] Try harder to preserve NSW information for sext(sub) expressions

Sanjoy Das via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 31 10:09:39 PDT 2017


sanjoy requested changes to this revision.
sanjoy added inline comments.
This revision now requires changes to proceed.


================
Comment at: lib/Analysis/ScalarEvolution.cpp:5964
+      if (BO->Opcode == Instruction::Sub && BO->Op) {
+        SCEV::NoWrapFlags Flags = getNoWrapFlagsFromUB(BO->Op);
+        if (maskFlags(Flags, SCEV::FlagNSW) == SCEV::FlagNSW) {
----------------
Why not use `BO->IsNSW`?


================
Comment at: test/Analysis/ScalarEvolution/flags-from-poison.ll:612
 ; CHECK: %index64 =
-; CHECK: --> {(sext i32 (-1 * %sub) to i64),+,1}<nsw>
+; CHECK: --> {(-1 * (sext i32 %sub to i64))<nsw>,+,1}<nsw
   %index64 = sext i32 %index32 to i64
----------------
Please add a test case that uses `Intrinsic::ssub_with_overflow`. 


Repository:
  rL LLVM

https://reviews.llvm.org/D35256





More information about the llvm-commits mailing list