Fix a README item: when doing a comparison with the result
[oota-llvm.git] / test / Transforms / Reassociate / basictest.ll
index ba0c9f210fcfeb14fb25a277c947e7cb28b68097..086474066c56154ba2317a5629bb5a7c3ff28ce2 100644 (file)
@@ -191,3 +191,26 @@ define i32 @test13(i32 %X1, i32 %X2, i32 %X3) {
 ; CHECK-NEXT: ret i32
 }
 
+; PR5359
+define i32 @test14(i32 %X1, i32 %X2) {
+  %B = mul i32 %X1, 47   ; X1*47
+  %C = mul i32 %X2, -47  ; X2*-47
+  %D = add i32 %B, %C    ; X1*47 + X2*-47 -> 47*(X1-X2)
+  ret i32 %D
+; CHECK: @test14
+; CHECK-NEXT: sub i32 %X1, %X2
+; CHECK-NEXT: mul i32 {{.*}}, 47
+; CHECK-NEXT: ret i32
+}
+
+; Do not reassociate expressions of type i1
+define i32 @test15(i32 %X1, i32 %X2, i32 %X3) {
+  %A = icmp ne i32 %X1, 0
+  %B = icmp slt i32 %X2, %X3
+  %C = and i1 %A, %B
+  %D = select i1 %C, i32 %X1, i32 0
+  ret i32 %D
+; CHECK: @test15
+; CHECK: and i1 %A, %B
+}
+