Index: llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp =================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp @@ -227,8 +227,8 @@ if (I.hasNoUnsignedWrap()) Shl->setHasNoUnsignedWrap(); if (I.hasNoSignedWrap()) { - uint64_t V; - if (match(NewCst, m_ConstantInt(V)) && V != Width - 1) + const APInt *V; + if (match(NewCst, m_APInt(V)) && *V != Width - 1) Shl->setHasNoSignedWrap(); } Index: llvm/trunk/test/Transforms/InstCombine/mul.ll =================================================================== --- llvm/trunk/test/Transforms/InstCombine/mul.ll +++ llvm/trunk/test/Transforms/InstCombine/mul.ll @@ -300,7 +300,7 @@ define <2 x i32> @test32vec(<2 x i32> %X) { ; CHECK-LABEL: @test32vec( -; CHECK-NEXT: [[MUL:%.*]] = shl <2 x i32> [[X:%.*]], +; CHECK-NEXT: [[MUL:%.*]] = shl nsw <2 x i32> [[X:%.*]], ; CHECK-NEXT: ret <2 x i32> [[MUL]] ; %mul = mul nsw <2 x i32> %X, @@ -315,20 +315,18 @@ ret i32 %mul } -; TODO: we should propagate nsw flag to the shift here define <2 x i32> @test33vec(<2 x i32> %X) { ; CHECK-LABEL: @test33vec( -; CHECK-NEXT: [[MUL:%.*]] = shl <2 x i32> [[X:%.*]], +; CHECK-NEXT: [[MUL:%.*]] = shl nsw <2 x i32> [[X:%.*]], ; CHECK-NEXT: ret <2 x i32> [[MUL]] ; %mul = mul nsw <2 x i32> %X, ret <2 x i32> %mul } -; TODO: we should propagate nsw flag to the shift here, but we only handle i64 and smaller define i128 @test34(i128 %X) { ; CHECK-LABEL: @test34( -; CHECK-NEXT: [[MUL:%.*]] = shl i128 [[X:%.*]], 1 +; CHECK-NEXT: [[MUL:%.*]] = shl nsw i128 [[X:%.*]], 1 ; CHECK-NEXT: ret i128 [[MUL]] ; %mul = mul nsw i128 %X, 2