Split up subtracts into add+negate if they have a reassociable use or operand
[oota-llvm.git] / test / Transforms / Reassociate / negation.ll
1 ; RUN: llvm-upgrade < %s | llvm-as | opt -reassociate -instcombine | llvm-dis | not grep sub
2
3 ; Test that we can turn things like X*-(Y*Z) -> X*-1*Y*Z.
4
5 int %test1(int %a, int %b, int %z) {
6         %c = sub int 0, %z
7         %d = mul int %a, %b
8         %e = mul int %c, %d
9         %f = mul int %e, 12345
10         %g = sub int 0, %f
11         ret int %g
12 }
13
14 int %test2(int %a, int %b, int %z) {
15         %d = mul int %z, 40
16         %c = sub int 0, %d
17         %e = mul int %a, %c
18         %f = sub int 0, %e
19         ret int %f
20 }