[PATCH] [IR] Fix the definition of 'shl nsw'

David Majnemer david.majnemer at gmail.com
Tue Apr 7 23:44:13 PDT 2015


================
Comment at: docs/LangRef.rst:5064
@@ +5063,3 @@
+
+If the ``nuw`` keyword is present, then the shift produces a :ref:`poison
+value <poisonvalues>` if ``op1`` \* ``1 << op2`` results in signed overflow.
----------------
sanjoy wrote:
> Should be ``nsw`` here.
Done.

================
Comment at: docs/LangRef.rst:5065
@@ +5064,3 @@
+If the ``nuw`` keyword is present, then the shift produces a :ref:`poison
+value <poisonvalues>` if ``op1`` \* ``1 << op2`` results in signed overflow.
+
----------------
sanjoy wrote:
> I'd use "if and only if" here.
Done.

================
Comment at: docs/LangRef.rst:5068
@@ -5066,2 +5067,3 @@
+As such, NUW/NSW have the same semantics as they
 would if the shift were expressed as a mul instruction with the same
 nsw/nuw bits in (mul %op1, (shl 1, %op2)).
----------------
sanjoy wrote:
> I'd prefer just removing this, and defining `nuw` directly, like `nsw`.
Done.

================
Comment at: lib/Analysis/InstructionSimplify.cpp:2302
@@ +2301,3 @@
+        if (CI2->isMinusOne()) {
+          // 'shl nsw -1, x' produces [-1 << (Width-2), -1]
+          ShiftAmount = Width - 2;
----------------
sanjoy wrote:
> Is this correct for `i1`?
`i1` is handled earlier.  I will add an assert to make that clear.

================
Comment at: test/Transforms/InstCombine/cast.ll:783
@@ -782,3 +782,3 @@
 ; CHECK-LABEL: @test69(
-  %o = shl nsw i64 %i, 3
+  %o = mul nsw i64 %i, 8
   %q = bitcast double* %p to i8*
----------------
sanjoy wrote:
> Why do we need to change this test?
I am changing these tests to as they were back in r219566.

http://reviews.llvm.org/D8890

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list