llvm-project/llvm/test/CodeGen/PowerPC/fast-isel-branch.ll
Chen Zheng eb7d16ea25 [PowerPC] make expensive mflr be away from its user in the function prologue
mflr is kind of expensive on Power version smaller than 10, so we should
schedule the store for the mflr's def away from mflr.

In epilogue, the expensive mtlr has no user for its def, so it doesn't
matter that the load and the mtlr are back-to-back.

Reviewed By: RolandF

Differential Revision: https://reviews.llvm.org/D137423
2022-11-14 21:14:20 -05:00

106 lines
2.8 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck %s -check-prefix=ELF64
; RUN: llc -mtriple=powerpc64-ibm-aix-xcoff < %s | FileCheck %s -check-prefix=AIX64
@x = global i32 1000, align 4
define signext i32 @bar() #0 {
; ELF64-LABEL: bar:
; ELF64: # %bb.0: # %entry
; ELF64-NEXT: mflr 0
; ELF64-NEXT: stdu 1, -48(1)
; ELF64-NEXT: std 0, 64(1)
; ELF64-NEXT: .cfi_def_cfa_offset 48
; ELF64-NEXT: .cfi_offset lr, 16
; ELF64-NEXT: li 3, 0
; ELF64-NEXT: stw 3, 44(1)
; ELF64-NEXT: li 3, 0
; ELF64-NEXT: stw 3, 40(1)
; ELF64-NEXT: .LBB0_1: # %for.cond
; ELF64-NEXT: #
; ELF64-NEXT: lwz 3, 40(1)
; ELF64-NEXT: addis 4, 2, .LC0@toc@ha
; ELF64-NEXT: ld 4, .LC0@toc@l(4)
; ELF64-NEXT: lwz 4, 0(4)
; ELF64-NEXT: cmpw 3, 4
; ELF64-NEXT: bge 0, .LBB0_4
; ELF64-NEXT: # %bb.2: # %for.body
; ELF64-NEXT: #
; ELF64-NEXT: bl foo
; ELF64-NEXT: nop
; ELF64-NEXT: # %bb.3: # %for.inc
; ELF64-NEXT: #
; ELF64-NEXT: lwz 3, 40(1)
; ELF64-NEXT: addi 3, 3, 1
; ELF64-NEXT: stw 3, 40(1)
; ELF64-NEXT: b .LBB0_1
; ELF64-NEXT: .LBB0_4: # %for.end
; ELF64-NEXT: li 3, 0
; ELF64-NEXT: addi 1, 1, 48
; ELF64-NEXT: ld 0, 16(1)
; ELF64-NEXT: mtlr 0
; ELF64-NEXT: blr
;
; AIX64-LABEL: bar:
; AIX64: # %bb.0: # %entry
; AIX64-NEXT: mflr 0
; AIX64-NEXT: stdu 1, -128(1)
; AIX64-NEXT: std 0, 144(1)
; AIX64-NEXT: li 3, 0
; AIX64-NEXT: stw 3, 124(1)
; AIX64-NEXT: li 3, 0
; AIX64-NEXT: stw 3, 120(1)
; AIX64-NEXT: L..BB0_1: # %for.cond
; AIX64-NEXT: #
; AIX64-NEXT: lwz 3, 120(1)
; AIX64-NEXT: ld 4, L..C0(2) # @x
; AIX64-NEXT: lwz 4, 0(4)
; AIX64-NEXT: cmpw 3, 4
; AIX64-NEXT: bge 0, L..BB0_4
; AIX64-NEXT: # %bb.2: # %for.body
; AIX64-NEXT: #
; AIX64-NEXT: bl .foo[PR]
; AIX64-NEXT: nop
; AIX64-NEXT: # %bb.3: # %for.inc
; AIX64-NEXT: #
; AIX64-NEXT: lwz 3, 120(1)
; AIX64-NEXT: addi 3, 3, 1
; AIX64-NEXT: stw 3, 120(1)
; AIX64-NEXT: b L..BB0_1
; AIX64-NEXT: L..BB0_4: # %for.end
; AIX64-NEXT: li 3, 0
; AIX64-NEXT: addi 1, 1, 128
; AIX64-NEXT: ld 0, 16(1)
; AIX64-NEXT: mtlr 0
; AIX64-NEXT: blr
entry:
%retval = alloca i32, align 4
%i = alloca i32, align 4
store i32 0, i32* %retval, align 4
store i32 0, i32* %i, align 4
br label %for.cond
for.cond:
%0 = load i32, i32* %i, align 4
%1 = load i32, i32* @x, align 4
%cmp = icmp slt i32 %0, %1
br i1 %cmp, label %for.body, label %for.end
for.body:
call void bitcast (void (...)* @foo to void ()*)()
br label %for.inc
for.inc:
%2 = load i32, i32* %i, align 4
%inc = add nsw i32 %2, 1
store i32 %inc, i32* %i, align 4
br label %for.cond
for.end:
ret i32 0
}
declare void @foo(...)
attributes #0 = { optnone noinline }