xref: /llvm-project/llvm/test/CodeGen/X86/code_placement_no_header_change.ll (revision f9f81289e6864ca3f09df16bad0ffc3ca58c3162)
181f3fd4bSGuozhi Wei; RUN: llc -mtriple=i686-linux < %s | FileCheck %s
281f3fd4bSGuozhi Wei
381f3fd4bSGuozhi Wei
481f3fd4bSGuozhi Weidefine i32 @bar(i32 %count) {
581f3fd4bSGuozhi Wei; Test checks that basic block backedge2 is not moved before header,
681f3fd4bSGuozhi Wei; because it can't reduce taken branches.
781f3fd4bSGuozhi Wei; Later backedge1 and backedge2 is rotated before loop header.
881f3fd4bSGuozhi Wei; CHECK-LABEL: bar
981f3fd4bSGuozhi Wei; CHECK: %.entry
10*f9f81289SJordan Rupprecht; CHECK: %.header
1181f3fd4bSGuozhi Wei; CHECK: %.backedge1
1281f3fd4bSGuozhi Wei; CHECK: %.backedge2
1381f3fd4bSGuozhi Wei; CHECK: %.exit
1481f3fd4bSGuozhi Wei.entry:
1581f3fd4bSGuozhi Wei  %c = shl nsw i32 %count, 2
1681f3fd4bSGuozhi Wei  br label %.header
1781f3fd4bSGuozhi Wei
1881f3fd4bSGuozhi Wei.header:
1981f3fd4bSGuozhi Wei  %val1 = call i32 @foo()
2081f3fd4bSGuozhi Wei  %cond1 = icmp sgt i32 %val1, 1
2181f3fd4bSGuozhi Wei  br i1 %cond1, label %.exit, label %.backedge1
2281f3fd4bSGuozhi Wei
2381f3fd4bSGuozhi Wei.backedge1:
2481f3fd4bSGuozhi Wei  %val2 = call i32 @foo()
2581f3fd4bSGuozhi Wei  %cond2 = icmp sgt i32 %val2, 1
2681f3fd4bSGuozhi Wei  br i1 %cond2, label %.header, label %.backedge2
2781f3fd4bSGuozhi Wei
2881f3fd4bSGuozhi Wei.backedge2:
2981f3fd4bSGuozhi Wei  %val3 = call i32 @foo()
3081f3fd4bSGuozhi Wei  br label %.header
3181f3fd4bSGuozhi Wei
3281f3fd4bSGuozhi Wei.exit:
3381f3fd4bSGuozhi Wei  ret i32 %c
3481f3fd4bSGuozhi Wei}
3581f3fd4bSGuozhi Wei
3681f3fd4bSGuozhi Weideclare i32 @foo()
37