1 ; RUN: llvm-as < %s | opt -reassociate -instcombine | llvm-dis | not grep sub
3 ; Test that we can turn things like X*-(Y*Z) -> X*-1*Y*Z.
5 define i32 @test1(i32 %a, i32 %b, i32 %z) {
6 %c = sub i32 0, %z ; <i32> [#uses=1]
7 %d = mul i32 %a, %b ; <i32> [#uses=1]
8 %e = mul i32 %c, %d ; <i32> [#uses=1]
9 %f = mul i32 %e, 12345 ; <i32> [#uses=1]
10 %g = sub i32 0, %f ; <i32> [#uses=1]
14 define i32 @test2(i32 %a, i32 %b, i32 %z) {
15 %d = mul i32 %z, 40 ; <i32> [#uses=1]
16 %c = sub i32 0, %d ; <i32> [#uses=1]
17 %e = mul i32 %a, %c ; <i32> [#uses=1]
18 %f = sub i32 0, %e ; <i32> [#uses=1]