[PATCH] D23296: [ValueTracking] Improve ValueTracking on left shift with nsw flag

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 8 23:14:49 PDT 2016


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

lgtm with some minor comments inline.


================
Comment at: lib/Analysis/ValueTracking.cpp:1028
@@ +1027,3 @@
+      if (NSW && KnownZero.isNegative())
+        KZResult |= APInt::getSignBit(BitWidth);
+      return KZResult;
----------------
Use `APInt::setBit` here and below (otherwise we'll unnecessarily allocate a new `APInt` if the bitwidth is larger than 64).

================
Comment at: test/Analysis/ValueTracking/known-signbit-shift.ll:20
@@ +19,3 @@
+  %c = or i32 %a, -2147483648
+  %d = and i32 %b, 7
+  %shift = shl nsw i32 %c, %d
----------------
Why do you need to `and` with `7` here?  Why not just `shl` directly with `%b`?


https://reviews.llvm.org/D23296





More information about the llvm-commits mailing list