• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -reassociate -S | FileCheck %s
2
3; These tests make sure that before processing insts
4; any previous instructions are already canonicalized.
5define i32 @foo(i32 %in) {
6; CHECK-LABEL: @foo
7; CHECK-NEXT: %factor = mul i32 %in, -4
8; CHECK-NEXT: %factor1 = mul i32 %in, 2
9; CHECK-NEXT: %_3 = add i32 %factor, 1
10; CHECK-NEXT: %_5 = add i32 %_3, %factor1
11; CHECK-NEXT: ret i32 %_5
12  %_0 = add i32 %in, 1
13  %_1 = mul i32 %in, -2
14  %_2 = add i32 %_0, %_1
15  %_3 = add i32 %_1, %_2
16  %_4 = add i32 %_3, 1
17  %_5 = add i32 %in, %_3
18  ret i32 %_5
19}
20
21; CHECK-LABEL: @foo1
22define void @foo1(float %in, i1 %cmp) {
23wrapper_entry:
24  br label %foo1
25
26for.body:
27  %0 = fadd float %in1, %in1
28  br label %foo1
29
30foo1:
31  %_0 = fmul fast float %in, -3.000000e+00
32  %_1 = fmul fast float %_0, 3.000000e+00
33  %in1 = fadd fast float -3.000000e+00, %_1
34  %in1use = fadd fast float %in1, %in1
35  br label %for.body
36
37
38}
39
40; CHECK-LABEL: @foo2
41define void @foo2(float %in, i1 %cmp) {
42wrapper_entry:
43  br label %for.body
44
45for.body:
46; If the operands of the phi are sheduled for processing before
47; foo1 is processed, the invariant of reassociate are not preserved
48  %unused = phi float [%in1, %foo1], [undef, %wrapper_entry]
49  br label %foo1
50
51foo1:
52  %_0 = fmul fast float %in, -3.000000e+00
53  %_1 = fmul fast float %_0, 3.000000e+00
54  %in1 = fadd fast float -3.000000e+00, %_1
55  %in1use = fadd fast float %in1, %in1
56  br label %for.body
57}
58