1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=verify,iroutliner -ir-outlining-no-cost < %s | FileCheck %s
4 ; This test looks at instances of constants in the different regions. If there
5 ; is a register in the same place as a constant in a similar region of code, we
6 ; do not outline those regions.
8 ; The first function tests that we do not outline with the register is
9 ; seen first, and the second function checks that we do not outline when the
10 ; constant is seen first.
12 define void @function_registers_first(i32 %0, i32 %1, i32 %2) {
13 ; CHECK-LABEL: @function_registers_first(
15 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
16 ; CHECK-NEXT: [[B:%.*]] = alloca i32, align 4
17 ; CHECK-NEXT: [[C:%.*]] = alloca i32, align 4
18 ; CHECK-NEXT: call void @outlined_ir_func_1(i32 [[TMP0:%.*]], ptr [[A]], i32 [[TMP1:%.*]], ptr [[B]], i32 [[TMP2:%.*]], ptr [[C]])
19 ; CHECK-NEXT: ret void
21 ; CHECK-NEXT: call void @outlined_ir_func_1(i32 2, ptr [[A]], i32 3, ptr [[B]], i32 4, ptr [[C]])
22 ; CHECK-NEXT: ret void
25 %a = alloca i32, align 4
26 %b = alloca i32, align 4
27 %c = alloca i32, align 4
28 store i32 %0, ptr %a, align 4
29 store i32 %1, ptr %b, align 4
30 store i32 %2, ptr %c, align 4
33 store i32 2, ptr %a, align 4
34 store i32 3, ptr %b, align 4
35 store i32 4, ptr %c, align 4
39 define void @function_with_constants_first(i32 %0, i32 %1, i32 %2) {
40 ; CHECK-LABEL: @function_with_constants_first(
42 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
43 ; CHECK-NEXT: [[B:%.*]] = alloca i32, align 4
44 ; CHECK-NEXT: [[C:%.*]] = alloca i32, align 4
45 ; CHECK-NEXT: [[AL:%.*]] = load i32, ptr [[A]], align 4
46 ; CHECK-NEXT: [[BL:%.*]] = load i32, ptr [[B]], align 4
47 ; CHECK-NEXT: [[CL:%.*]] = load i32, ptr [[C]], align 4
48 ; CHECK-NEXT: call void @outlined_ir_func_0(i32 2, i32 [[AL]], i32 3, i32 [[BL]], i32 4, i32 [[CL]])
49 ; CHECK-NEXT: ret void
51 ; CHECK-NEXT: call void @outlined_ir_func_0(i32 [[TMP0:%.*]], i32 [[AL]], i32 [[TMP1:%.*]], i32 [[BL]], i32 [[TMP2:%.*]], i32 [[CL]])
52 ; CHECK-NEXT: ret void
55 %a = alloca i32, align 4
56 %b = alloca i32, align 4
57 %c = alloca i32, align 4
58 %al = load i32, ptr %a
59 %bl = load i32, ptr %b
60 %cl = load i32, ptr %c
72 ; CHECK: define internal void @outlined_ir_func_0(i32 [[ARG0:%.*]], i32 [[ARG1:%.*]], i32 [[ARG2:%.*]], i32 [[ARG3:%.*]], i32 [[ARG4:%.*]], i32 [[ARG5:%.*]])
73 ; CHECK: entry_to_outline:
74 ; CHECK-NEXT: add i32 [[ARG0]], [[ARG1]]
75 ; CHECK-NEXT: add i32 [[ARG2]], [[ARG3]]
76 ; CHECK-NEXT: add i32 [[ARG4]], [[ARG5]]
78 ; CHECK: define internal void @outlined_ir_func_1(i32 [[ARG0:%.*]], ptr [[ARG1:%.*]], i32 [[ARG2:%.*]], ptr [[ARG3:%.*]], i32 [[ARG4:%.*]], ptr [[ARG5:%.*]])
79 ; CHECK: entry_to_outline:
80 ; CHECK-NEXT: store i32 [[ARG0]], ptr [[ARG1]]
81 ; CHECK-NEXT: store i32 [[ARG2]], ptr [[ARG3]]
82 ; CHECK-NEXT: store i32 [[ARG4]], ptr [[ARG5]]