xref: /llvm-project/llvm/test/Transforms/CodeGenPrepare/X86/split-indirect-loop.ll (revision f1ec0d12bb0843f0deab83ef2b5cf1339cbc4f0b)
1; RUN: opt -passes='require<profile-summary>,function(codegenprepare)' -S -mtriple=x86_64 < %s | FileCheck %s
2
3; Test that an invalid CFG is not created by splitIndirectCriticalEdges
4; transformation when the 'target' block is a loop to itself.
5
6; CHECK: .split:
7; CHECK: br label %while.body.clone
8; CHECK: if.else1:
9; CHECK: indirectbr
10; CHECK: while.body.clone:
11; CHECK: br label %.split
12
13define void @test(i1 %c) {
14entry:
15  br label %if.else
16
17if.else:
18  br i1 %c, label %while.body, label %preheader
19
20preheader:
21  br label %if.else1
22
23if.then:
24  unreachable
25
26while.body:
27  %dest.sroa = phi i32 [ %1, %while.body ], [ undef, %if.else1 ], [ undef, %if.else ]
28  %0 = inttoptr i32 %dest.sroa to ptr
29  %incdec.ptr = getelementptr inbounds i8, ptr %0, i32 -1
30  %1 = ptrtoint ptr %incdec.ptr to i32
31  store i8 undef, ptr %incdec.ptr, align 1
32  br label %while.body
33
34if.else1:
35  indirectbr ptr undef, [label %if.then, label %while.body, label %if.else, label %if.else1]
36}
37
38