1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=gvn -enable-split-backedge-in-load-pre=true < %s | FileCheck %s --check-prefix=ON
3 ; RUN: opt -S -passes=gvn -enable-split-backedge-in-load-pre=false < %s | FileCheck %s --check-prefix=OFF
5 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32"
7 define i32 @test(i1 %b, i1 %c, ptr noalias %p, ptr noalias %q) {
10 ; ON-NEXT: [[Y1:%.*]] = load i32, ptr [[P:%.*]], align 4
11 ; ON-NEXT: call void @use(i32 [[Y1]])
12 ; ON-NEXT: br label [[HEADER:%.*]]
14 ; ON-NEXT: [[Y:%.*]] = phi i32 [ [[Y_PRE:%.*]], [[SKIP_HEADER_CRIT_EDGE:%.*]] ], [ [[Y]], [[HEADER]] ], [ [[Y1]], [[ENTRY:%.*]] ]
15 ; ON-NEXT: call void @use(i32 [[Y]])
16 ; ON-NEXT: br i1 [[B:%.*]], label [[SKIP:%.*]], label [[HEADER]]
18 ; ON-NEXT: call void @clobber(ptr [[P]], ptr [[Q:%.*]])
19 ; ON-NEXT: br i1 [[C:%.*]], label [[SKIP_HEADER_CRIT_EDGE]], label [[EXIT:%.*]]
20 ; ON: skip.header_crit_edge:
21 ; ON-NEXT: [[Y_PRE]] = load i32, ptr [[P]], align 4
22 ; ON-NEXT: br label [[HEADER]]
24 ; ON-NEXT: ret i32 [[Y]]
28 ; OFF-NEXT: [[Y1:%.*]] = load i32, ptr [[P:%.*]], align 4
29 ; OFF-NEXT: call void @use(i32 [[Y1]])
30 ; OFF-NEXT: br label [[HEADER:%.*]]
32 ; OFF-NEXT: [[Y:%.*]] = load i32, ptr [[P]], align 4
33 ; OFF-NEXT: call void @use(i32 [[Y]])
34 ; OFF-NEXT: br i1 [[B:%.*]], label [[SKIP:%.*]], label [[HEADER]]
36 ; OFF-NEXT: call void @clobber(ptr [[P]], ptr [[Q:%.*]])
37 ; OFF-NEXT: br i1 [[C:%.*]], label [[HEADER]], label [[EXIT:%.*]]
39 ; OFF-NEXT: ret i32 [[Y]]
42 %y1 = load i32, ptr %p
43 call void @use(i32 %y1)
47 call void @use(i32 %y)
48 br i1 %b, label %skip, label %header
50 call void @clobber(ptr %p, ptr %q)
51 br i1 %c, label %header, label %exit
56 declare void @use(i32) readonly
57 declare void @clobber(ptr %p, ptr %q)