mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-24 22:32:47 +00:00
f08cddcf56
Note: This was originally reverted to track down a buildbot error. This commit exposed a latent bug that was fixed in r215753. Therefore it is reapplied without any modifications. I run it through SPEC2k and SPEC2k6 for AArch64 and it didn't introduce any new regeressions. Original commit message: This changes the order in which FastISel tries to materialize a constant. Originally it would try to use a simple target-independent approach, which can lead to the generation of inefficient code. On X86 this would result in the use of movabsq to materialize any 64bit integer constant - even for simple and small values such as 0 and 1. Also some very funny floating-point materialization could be observed too. On AArch64 it would materialize the constant 0 in a register even the architecture has an actual "zero" register. On ARM it would generate unnecessary mov instructions or not use mvn. This change simply changes the order and always asks the target first if it likes to materialize the constant. This doesn't fix all the issues mentioned above, but it enables the targets to implement such optimizations. Related to <rdar://problem/17420988>. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216006 91177308-0d34-0410-b5e6-96231b3b80d8
133 lines
3.1 KiB
LLVM
133 lines
3.1 KiB
LLVM
; RUN: llc < %s -O0 -verify-machineinstrs -fast-isel-abort -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr7 | FileCheck %s --check-prefix=ELF64
|
|
|
|
define i32 @t1(i8 signext %a) nounwind {
|
|
%1 = sext i8 %a to i32
|
|
ret i32 %1
|
|
}
|
|
|
|
define i32 @t2(i8 zeroext %a) nounwind {
|
|
%1 = zext i8 %a to i32
|
|
ret i32 %1
|
|
}
|
|
|
|
define i32 @t3(i16 signext %a) nounwind {
|
|
%1 = sext i16 %a to i32
|
|
ret i32 %1
|
|
}
|
|
|
|
define i32 @t4(i16 zeroext %a) nounwind {
|
|
%1 = zext i16 %a to i32
|
|
ret i32 %1
|
|
}
|
|
|
|
define void @foo(i8 %a, i16 %b) nounwind {
|
|
; ELF64: foo
|
|
%1 = call i32 @t1(i8 signext %a)
|
|
; ELF64: extsb
|
|
%2 = call i32 @t2(i8 zeroext %a)
|
|
; ELF64: rldicl {{[0-9]+}}, {{[0-9]+}}, 0, 56
|
|
%3 = call i32 @t3(i16 signext %b)
|
|
; ELF64: extsh
|
|
%4 = call i32 @t4(i16 zeroext %b)
|
|
; ELF64: rldicl {{[0-9]+}}, {{[0-9]+}}, 0, 48
|
|
|
|
;; A few test to check materialization
|
|
%5 = call i32 @t2(i8 zeroext 255)
|
|
; ELF64: rldicl {{[0-9]+}}, {{[0-9]+}}, 0, 56
|
|
%6 = call i32 @t4(i16 zeroext 65535)
|
|
; ELF64: rldicl {{[0-9]+}}, {{[0-9]+}}, 0, 48
|
|
ret void
|
|
}
|
|
|
|
define void @foo2() nounwind {
|
|
%1 = call signext i16 @t5()
|
|
%2 = call zeroext i16 @t6()
|
|
%3 = call signext i8 @t7()
|
|
%4 = call zeroext i8 @t8()
|
|
ret void
|
|
}
|
|
|
|
declare signext i16 @t5();
|
|
declare zeroext i16 @t6();
|
|
declare signext i8 @t7();
|
|
declare zeroext i8 @t8();
|
|
|
|
define i32 @t10(i32 %argc, i8** nocapture %argv) {
|
|
entry:
|
|
; ELF64: t10
|
|
%call = call i32 @bar(i8 zeroext 0, i8 zeroext -8, i8 zeroext -69, i8 zeroext 28, i8 zeroext 40, i8 zeroext -70)
|
|
; ELF64: li 3, 0
|
|
; ELF64: li 4, -8
|
|
; ELF64: li 5, -69
|
|
; ELF64: li 6, 28
|
|
; ELF64: li 7, 40
|
|
; ELF64: li 8, -70
|
|
; ELF64: rldicl 3, 3, 0, 56
|
|
; ELF64: rldicl 4, 4, 0, 56
|
|
; ELF64: rldicl 5, 5, 0, 56
|
|
; ELF64: rldicl 6, 6, 0, 56
|
|
; ELF64: rldicl 7, 7, 0, 56
|
|
; ELF64: rldicl 8, 8, 0, 56
|
|
ret i32 0
|
|
}
|
|
|
|
declare i32 @bar(i8 zeroext, i8 zeroext, i8 zeroext, i8 zeroext, i8 zeroext, i8 zeroext)
|
|
|
|
define i32 @bar0(i32 %i) nounwind {
|
|
ret i32 0
|
|
}
|
|
|
|
; Function pointers are not yet implemented.
|
|
;define void @foo3() uwtable {
|
|
; %fptr = alloca i32 (i32)*, align 8
|
|
; store i32 (i32)* @bar0, i32 (i32)** %fptr, align 8
|
|
; %1 = load i32 (i32)** %fptr, align 8
|
|
; %call = call i32 %1(i32 0)
|
|
; ret void
|
|
;}
|
|
|
|
; Intrinsic calls not yet implemented, and udiv isn't one for PPC anyway.
|
|
;define i32 @LibCall(i32 %a, i32 %b) {
|
|
;entry:
|
|
; %tmp1 = udiv i32 %a, %b ; <i32> [#uses=1]
|
|
; ret i32 %tmp1
|
|
;}
|
|
|
|
declare void @float_foo(float %f) ssp
|
|
|
|
define void @float_const() ssp {
|
|
entry:
|
|
; ELF64: float_const
|
|
call void @float_foo(float 0x401C666660000000)
|
|
; ELF64: addis [[REG:[0-9]+]], 2, .LCPI[[SUF:[0-9_]+]]@toc@ha
|
|
; ELF64: lfs 1, .LCPI[[SUF]]@toc@l([[REG]])
|
|
ret void
|
|
}
|
|
|
|
define void @float_reg(float %dummy, float %f) ssp {
|
|
entry:
|
|
; ELF64: float_reg
|
|
call void @float_foo(float %f)
|
|
; ELF64: fmr 1, 2
|
|
ret void
|
|
}
|
|
|
|
declare void @double_foo(double %d) ssp
|
|
|
|
define void @double_const() ssp {
|
|
entry:
|
|
; ELF64: double_const
|
|
call void @double_foo(double 0x1397723CCABD0000401C666660000000)
|
|
; ELF64: addis [[REG2:[0-9]+]], 2, .LCPI[[SUF2:[0-9_]+]]@toc@ha
|
|
; ELF64: lfd 1, .LCPI[[SUF2]]@toc@l([[REG2]])
|
|
ret void
|
|
}
|
|
|
|
define void @double_reg(double %dummy, double %d) ssp {
|
|
entry:
|
|
; ELF64: double_reg
|
|
call void @double_foo(double %d)
|
|
; ELF64: fmr 1, 2
|
|
ret void
|
|
}
|