llvm-project/llvm/test/CodeGen/X86/callbr-asm-loop.ll
XChy f393f2a61e
[BranchFolding] Avoid moving blocks to fall through to an indirect target (#152916)
Depend on #152591 to fix
https://github.com/llvm/llvm-project/issues/149023.
Similar to an EH pad, there is no real advantage in "falling through" to
an indirect target of an INLINEASM_BR. And multiple indirect targets of
inline asm at the end of a function may be rotated infinitely.
Therefore, this patch avoids such optimization on indirect target of
inline asm as fall through.
2025-08-14 16:18:36 +09:00

41 lines
1.3 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
; RUN: llc -O1 -mtriple=i686-- < %s | FileCheck %s
; Test that causes multiple defs of %eax.
define i32 @loop1() nounwind {
; CHECK-LABEL: loop1:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: .p2align 4
; CHECK-NEXT: .LBB0_1: # %tailrecurse
; CHECK-NEXT: # =>This Inner Loop Header: Depth=1
; CHECK-NEXT: xorl %eax, %eax
; CHECK-NEXT: movl $1, %edx
; CHECK-NEXT: #APP
; CHECK-NEXT: #NO_APP
; CHECK-NEXT: jmp .LBB0_1
; CHECK-NEXT: .LBB0_2: # Inline asm indirect target
; CHECK-NEXT: # %tailrecurse.tailrecurse_crit_edge
; CHECK-NEXT: # in Loop: Header=BB0_1 Depth=1
; CHECK-NEXT: # Label of block must be emitted
; CHECK-NEXT: jmp .LBB0_1
; CHECK-NEXT: .LBB0_3: # Inline asm indirect target
; CHECK-NEXT: # %lab2.split
; CHECK-NEXT: # Label of block must be emitted
; CHECK-NEXT: movl %edx, %eax
; CHECK-NEXT: retl
entry:
br label %tailrecurse
tailrecurse:
%0 = callbr { i32, i32 } asm "", "={ax},={dx},0,1,!i,!i"(i32 0, i32 1) #1
to label %tailrecurse.backedge [label %tailrecurse.backedge, label %lab2.split]
tailrecurse.backedge:
br label %tailrecurse
lab2.split:
%asmresult5 = extractvalue { i32, i32 } %0, 1
ret i32 %asmresult5
}