[Reassociate] Canonicalize negative constants out of expressions.
[oota-llvm.git] / test / Transforms / Reassociate / otherops.ll
1 ; Reassociation should apply to Add, Mul, And, Or, & Xor
2 ;
3 ; RUN: opt < %s -reassociate -constprop -instcombine -die -S | FileCheck %s
4
5 define i32 @test_mul(i32 %arg) {
6 ; CHECK-LABEL: test_mul
7 ; CHECK-NEXT: %tmp2 = mul i32 %arg, 144
8 ; CHECK-NEXT: ret i32 %tmp2
9
10   %tmp1 = mul i32 12, %arg
11   %tmp2 = mul i32 %tmp1, 12
12   ret i32 %tmp2
13 }
14
15 define i32 @test_and(i32 %arg) {
16 ; CHECK-LABEL: test_and
17 ; CHECK-NEXT: %tmp2 = and i32 %arg, 14
18 ; CHECK-NEXT: ret i32 %tmp2
19
20   %tmp1 = and i32 14, %arg
21   %tmp2 = and i32 %tmp1, 14
22   ret i32 %tmp2
23 }
24
25 define i32 @test_or(i32 %arg) {
26 ; CHECK-LABEL: test_or
27 ; CHECK-NEXT: %tmp2 = or i32 %arg, 14
28 ; CHECK-NEXT: ret i32 %tmp2
29
30   %tmp1 = or i32 14, %arg
31   %tmp2 = or i32 %tmp1, 14
32   ret i32 %tmp2
33 }
34
35 define i32 @test_xor(i32 %arg) {
36 ; CHECK-LABEL: test_xor
37 ; CHECK-NEXT: ret i32 %arg
38
39   %tmp1 = xor i32 12, %arg
40   %tmp2 = xor i32 %tmp1, 12
41   ret i32 %tmp2
42 }