xref: /llvm-project/llvm/test/Transforms/IROutliner/outlining-same-globals.ll (revision f4b925ee7078f058602fd323e25f45f1ae91ca34)
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@global1 = global i32 1, align 4
5@global2 = global i32 2, align 4
6
7; This test looks at the globals in the regions, and if it they are the
8; same it outlines the region without elevating the globals to arguments.
9
10define void @outline_globals1() {
11; CHECK-LABEL: @outline_globals1(
12; CHECK-NEXT:  entry:
13; CHECK-NEXT:    call void @outlined_ir_func_0()
14; CHECK-NEXT:    ret void
15;
16entry:
17  %0 = load i32, ptr @global1
18  %1 = load i32, ptr @global2
19  %2 = add i32 %0, %1
20  ret void
21}
22
23define void @outline_globals2() {
24; CHECK-LABEL: @outline_globals2(
25; CHECK-NEXT:  entry:
26; CHECK-NEXT:    call void @outlined_ir_func_0()
27; CHECK-NEXT:    ret void
28;
29entry:
30  %0 = load i32, ptr @global1
31  %1 = load i32, ptr @global2
32  %2 = add i32 %0, %1
33  ret void
34}
35
36; CHECK: define internal void @outlined_ir_func_0()
37; CHECK: entry_to_outline:
38; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr @global1, align 4
39; CHECK-NEXT: [[TMP2:%.*]] = load i32, ptr @global2, align 4
40; CHECK-NEXT: [[ADD:%.*]] = add i32 [[TMP1]], [[TMP2]]
41
42