Home | History | Annotate | Download | only in Reassociate
      1 ; RUN: opt < %s -reassociate -instcombine -S | not grep sub
      2 
      3 ; Test that we can turn things like X*-(Y*Z) -> X*-1*Y*Z.
      4 
      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]
     11 	ret i32 %g
     12 }
     13 
     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]
     19 	ret i32 %f
     20 }
     21 
     22