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 3 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. 7 8%struct.RT = type { i8, [10 x [20 x i32]], i8 } 9%struct.ST = type { i32, double, %struct.RT } 10 11define void @function1(ptr %s, i64 %t) { 12; CHECK-LABEL: @function1( 13; CHECK-NEXT: entry: 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 18; 19entry: 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 25 ret void 26} 27 28define void @function2(ptr %s, i64 %t) { 29; CHECK-LABEL: @function2( 30; CHECK-NEXT: entry: 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 35; 36entry: 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 42 ret void 43} 44 45define void @function3(ptr %s, i64 %t) { 46; CHECK-LABEL: @function3( 47; CHECK-NEXT: entry: 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 54; 55entry: 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 61 ret void 62} 63 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 69