InstCombine: Preserve nsw/nuw for ((X << C2)*C1) -> (X * (C1 << C2))
[oota-llvm.git] / test / Transforms / InstCombine / mul.ll
index 905c33b501f4ffae5aebac9d97ba95fede936d54..469ca5a0b95cc99b3b46158b97ecf9bf951aa0dc 100644 (file)
@@ -204,3 +204,19 @@ define i32 @test22(i32 %A) {
         ret i32 %B
 ; CHECK: sub nsw i32 0, %A
 }
+
+define i32 @test23(i32 %A) {
+; CHECK-LABEL: @test23(
+        %B = shl nuw i32 %A, 1
+        %C = mul nuw i32 %B, 3
+        ret i32 %C
+; CHECK: mul nuw i32 %A, 6
+}
+
+define i32 @test24(i32 %A) {
+; CHECK-LABEL: @test24(
+        %B = shl nsw i32 %A, 1
+        %C = mul nsw i32 %B, 3
+        ret i32 %C
+; CHECK: mul nsw i32 %A, 6
+}