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 checks to make sure that we outline getelementptr instructions only
5 ; when all the operands after the first are the exact same. In this case, we
6 ; outline from the first two functions, but not the third.
8 %struct.RT = type { i8, [10 x [20 x i32]], i8 }
9 %struct.ST = type { i32, double, %struct.RT }
11 define void @function1(ptr %s, i64 %t) {
12 ; CHECK-LABEL: @function1(
14 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
15 ; CHECK-NEXT: [[B:%.*]] = alloca i32, align 4
16 ; CHECK-NEXT: call void @outlined_ir_func_0(ptr [[A]], ptr [[B]], ptr [[S:%.*]], i64 [[T:%.*]])
17 ; CHECK-NEXT: ret void
20 %a = alloca i32, align 4
21 %b = alloca i32, align 4
22 store i32 2, ptr %a, align 4
23 store i32 3, ptr %b, align 4
24 %0 = getelementptr inbounds %struct.ST, ptr %s, i64 %t, i32 1
28 define void @function2(ptr %s, i64 %t) {
29 ; CHECK-LABEL: @function2(
31 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
32 ; CHECK-NEXT: [[B:%.*]] = alloca i32, align 4
33 ; CHECK-NEXT: call void @outlined_ir_func_0(ptr [[A]], ptr [[B]], ptr [[S:%.*]], i64 [[T:%.*]])
34 ; CHECK-NEXT: ret void
37 %a = alloca i32, align 4
38 %b = alloca i32, align 4
39 store i32 2, ptr %a, align 4
40 store i32 3, ptr %b, align 4
41 %0 = getelementptr inbounds %struct.ST, ptr %s, i64 %t, i32 1
45 define void @function3(ptr %s, i64 %t) {
46 ; CHECK-LABEL: @function3(
48 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
49 ; CHECK-NEXT: [[B:%.*]] = alloca i32, align 4
50 ; CHECK-NEXT: store i32 2, ptr [[A]], align 4
51 ; CHECK-NEXT: store i32 3, ptr [[B]], align 4
52 ; CHECK-NEXT: [[TMP0:%.*]] = getelementptr inbounds [[STRUCT_ST:%.*]], ptr [[S:%.*]], i64 [[T:%.*]], i32 0
53 ; CHECK-NEXT: ret void
56 %a = alloca i32, align 4
57 %b = alloca i32, align 4
58 store i32 2, ptr %a, align 4
59 store i32 3, ptr %b, align 4
60 %0 = getelementptr inbounds %struct.ST, ptr %s, i64 %t, i32 0
64 ; CHECK: define internal void @outlined_ir_func_0(ptr [[ARG0:%.*]], ptr [[ARG1:%.*]], ptr [[ARG2:%.*]], i64 [[ARG3:%.*]])
65 ; CHECK: entry_to_outline:
66 ; CHECK-NEXT: store i32 2, ptr [[ARG0]], align 4
67 ; CHECK-NEXT: store i32 3, ptr [[ARG1]], align 4
68 ; CHECK-NEXT: [[TMP0:%.*]] = getelementptr inbounds %struct.ST, ptr [[ARG2]], i64 [[ARG3]], i32 1