llvm.org GIT mirror llvm / ef3144e
[Reassociate] add tests for binop with identity constant; NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336214 91177308-0d34-0410-b5e6-96231b3b80d8 Sanjay Patel 1 year, 2 months ago
1 changed file(s) with 74 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
1 ; RUN: opt < %s -reassociate -S | FileCheck %s
2
3 ; Don't produce an instruction that is a no-op because the constant is an identity constant.
4
5 define i32 @add_0(i32 %x) {
6 ; CHECK-LABEL: @add_0(
7 ; CHECK-NEXT: ret i32 [[X:%.*]]
8 ;
9 %a1 = add i32 %x, -30
10 %a2 = add i32 %a1, 30
11 ret i32 %a2
12 }
13
14 define i32 @mul_1(i32 %x) {
15 ; CHECK-LABEL: @mul_1(
16 ; CHECK-NEXT: ret i32 [[X:%.*]]
17 ;
18 %a1 = mul i32 %x, -1
19 %a2 = mul i32 %a1, -1
20 ret i32 %a2
21 }
22
23 define i8 @and_neg1(i8 %x) {
24 ; CHECK-LABEL: @and_neg1(
25 ; CHECK-NEXT: ret i8 [[X:%.*]]
26 ;
27 %a1 = and i8 %x, 255
28 %a2 = and i8 %a1, 255
29 ret i8 %a2
30 }
31
32 define i8 @or_0(i8 %x) {
33 ; CHECK-LABEL: @or_0(
34 ; CHECK-NEXT: ret i8 [[X:%.*]]
35 ;
36 %a1 = or i8 %x, 0
37 %a2 = or i8 %a1, 0
38 ret i8 %a2
39 }
40
41 define i8 @xor_0(i8 %x) {
42 ; CHECK-LABEL: @xor_0(
43 ; CHECK-NEXT: ret i8 [[X:%.*]]
44 ;
45 %a1 = xor i8 %x, 42
46 %a2 = xor i8 %a1, 42
47 ret i8 %a2
48 }
49
50 ; FIXME
51
52 define float @fadd_0(float %x) {
53 ; CHECK-LABEL: @fadd_0(
54 ; CHECK-NEXT: [[A2:%.*]] = fadd fast float [[X:%.*]], 0.000000e+00
55 ; CHECK-NEXT: ret float [[A2]]
56 ;
57 %a1 = fadd fast float %x, -30.0
58 %a2 = fadd fast float %a1, 30.0
59 ret float %a2
60 }
61
62 ; FIXME
63
64 define float @fmul_1(float %x) {
65 ; CHECK-LABEL: @fmul_1(
66 ; CHECK-NEXT: [[A2:%.*]] = fmul fast float [[X:%.*]], 1.000000e+00
67 ; CHECK-NEXT: ret float [[A2]]
68 ;
69 %a1 = fmul fast float %x, 4.0
70 %a2 = fmul fast float %a1, 0.25
71 ret float %a2
72 }
73