1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -verify -iroutliner -ir-outlining-no-cost < %s | FileCheck %s
4 ; This test checks that floating point commutative instructions are not treated
5 ; as commutative. Even though an ffadd is technically commutative, the order
6 ; of operands still needs to be enforced since the process of fadding floating
7 ; point values requires the order to be the same.
9 ; We make sure that we outline the identical regions from the first two
10 ; functions, but not the third. this is because the operands are in a different
11 ; order in a floating point instruction in this section.
13 define void @outline_from_fadd1() {
14 ; CHECK-LABEL: @outline_from_fadd1(
16 ; CHECK-NEXT: [[A:%.*]] = alloca double, align 4
17 ; CHECK-NEXT: [[B:%.*]] = alloca double, align 4
18 ; CHECK-NEXT: [[C:%.*]] = alloca double, align 4
19 ; CHECK-NEXT: call void @outlined_ir_func_0(double* [[A]], double* [[B]], double* [[C]])
20 ; CHECK-NEXT: ret void
23 %a = alloca double, align 4
24 %b = alloca double, align 4
25 %c = alloca double, align 4
26 store double 2.0, double* %a, align 4
27 store double 3.0, double* %b, align 4
28 store double 4.0, double* %c, align 4
29 %al = load double, double* %a
30 %bl = load double, double* %b
31 %cl = load double, double* %c
32 %0 = fadd double %al, %bl
33 %1 = fadd double %al, %cl
34 %2 = fadd double %bl, %cl
38 define void @outline_from_fadd2.0() {
39 ; CHECK-LABEL: @outline_from_fadd2.0(
41 ; CHECK-NEXT: [[A:%.*]] = alloca double, align 4
42 ; CHECK-NEXT: [[B:%.*]] = alloca double, align 4
43 ; CHECK-NEXT: [[C:%.*]] = alloca double, align 4
44 ; CHECK-NEXT: call void @outlined_ir_func_0(double* [[A]], double* [[B]], double* [[C]])
45 ; CHECK-NEXT: ret void
48 %a = alloca double, align 4
49 %b = alloca double, align 4
50 %c = alloca double, align 4
51 store double 2.0, double* %a, align 4
52 store double 3.0, double* %b, align 4
53 store double 4.0, double* %c, align 4
54 %al = load double, double* %a
55 %bl = load double, double* %b
56 %cl = load double, double* %c
57 %0 = fadd double %al, %bl
58 %1 = fadd double %al, %cl
59 %2 = fadd double %bl, %cl
63 define void @outline_from_flipped_fadd3.0() {
64 ; CHECK-LABEL: @outline_from_flipped_fadd3.0(
66 ; CHECK-NEXT: [[A:%.*]] = alloca double, align 4
67 ; CHECK-NEXT: [[B:%.*]] = alloca double, align 4
68 ; CHECK-NEXT: [[C:%.*]] = alloca double, align 4
69 ; CHECK-NEXT: store double 2.000000e+00, double* [[A]], align 4
70 ; CHECK-NEXT: store double 3.000000e+00, double* [[B]], align 4
71 ; CHECK-NEXT: store double 4.000000e+00, double* [[C]], align 4
72 ; CHECK-NEXT: [[AL:%.*]] = load double, double* [[A]], align 8
73 ; CHECK-NEXT: [[BL:%.*]] = load double, double* [[B]], align 8
74 ; CHECK-NEXT: [[CL:%.*]] = load double, double* [[C]], align 8
75 ; CHECK-NEXT: [[TMP0:%.*]] = fadd double [[BL]], [[AL]]
76 ; CHECK-NEXT: [[TMP1:%.*]] = fadd double [[CL]], [[AL]]
77 ; CHECK-NEXT: [[TMP2:%.*]] = fadd double [[CL]], [[BL]]
78 ; CHECK-NEXT: ret void
81 %a = alloca double, align 4
82 %b = alloca double, align 4
83 %c = alloca double, align 4
84 store double 2.0, double* %a, align 4
85 store double 3.0, double* %b, align 4
86 store double 4.0, double* %c, align 4
87 %al = load double, double* %a
88 %bl = load double, double* %b
89 %cl = load double, double* %c
90 %0 = fadd double %bl, %al
91 %1 = fadd double %cl, %al
92 %2 = fadd double %cl, %bl
96 ; CHECK: define internal void @outlined_ir_func_0(double* [[ARG0:%.*]], double* [[ARG1:%.*]], double* [[ARG2:%.*]]) #0 {
97 ; CHECK: entry_to_outline:
98 ; CHECK-NEXT: store double 2.000000e+00, double* [[ARG0]], align 4
99 ; CHECK-NEXT: store double 3.000000e+00, double* [[ARG1]], align 4
100 ; CHECK-NEXT: store double 4.000000e+00, double* [[ARG2]], align 4
101 ; CHECK-NEXT: [[AL:%.*]] = load double, double* [[ARG0]], align 8
102 ; CHECK-NEXT: [[BL:%.*]] = load double, double* [[ARG1]], align 8
103 ; CHECK-NEXT: [[CL:%.*]] = load double, double* [[ARG2]], align 8
104 ; CHECK-NEXT: [[TMP0:%.*]] = fadd double [[AL]], [[BL]]
105 ; CHECK-NEXT: [[TMP1:%.*]] = fadd double [[AL]], [[CL]]
106 ; CHECK-NEXT: [[TMP2:%.*]] = fadd double [[BL]], [[CL]]