mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-09-02 11:30:10 +00:00
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
94 lines
2.3 KiB
LLVM
94 lines
2.3 KiB
LLVM
; RUN: llc -O0 -verify-machineinstrs -fast-isel-abort -relocation-model=dynamic-no-pic -arm-use-movt=false -mtriple=armv7-apple-ios < %s | FileCheck %s --check-prefix=CHECK --check-prefix=ARM
|
|
; RUN: llc -O0 -verify-machineinstrs -fast-isel-abort -relocation-model=dynamic-no-pic -arm-use-movt=false -mtriple=armv7-linux-gnueabi < %s | FileCheck %s --check-prefix=CHECK --check-prefix=ARM
|
|
; RUN: llc -O0 -verify-machineinstrs -fast-isel-abort -relocation-model=dynamic-no-pic -arm-use-movt=false -mtriple=thumbv7-apple-ios < %s | FileCheck %s --check-prefix=CHECK --check-prefix=ARM
|
|
; RUN: llc -O0 -verify-machineinstrs -fast-isel-abort -relocation-model=dynamic-no-pic -arm-use-movt=true -mtriple=thumbv7-apple-ios < %s | FileCheck %s --check-prefix=CHECK --check-prefix=THUMB
|
|
; RUN: llc -O0 -verify-machineinstrs -fast-isel-abort -relocation-model=dynamic-no-pic -arm-use-movt=true -mtriple=armv7-apple-ios < %s | FileCheck %s --check-prefix=MOVT
|
|
; rdar://10412592
|
|
|
|
define void @t1() nounwind {
|
|
entry:
|
|
; CHECK-LABEL: t1
|
|
; CHECK: mvn r0, #0
|
|
call void @foo(i32 -1)
|
|
ret void
|
|
}
|
|
|
|
declare void @foo(i32)
|
|
|
|
define void @t2() nounwind {
|
|
entry:
|
|
; CHECK-LABEL: t2
|
|
; CHECK: mvn r0, #233
|
|
call void @foo(i32 -234)
|
|
ret void
|
|
}
|
|
|
|
define void @t3() nounwind {
|
|
entry:
|
|
; CHECK-LABEL: t3
|
|
; CHECK: mvn r0, #256
|
|
call void @foo(i32 -257)
|
|
ret void
|
|
}
|
|
|
|
; Load from constant pool
|
|
define void @t4() nounwind {
|
|
entry:
|
|
; ARM-LABEL: t4
|
|
; ARM: ldr r0
|
|
; THUMB-LABEL: t4
|
|
; THUMB: movw r0, #65278
|
|
; THUMB: movt r0, #65535
|
|
call void @foo(i32 -258)
|
|
ret void
|
|
}
|
|
|
|
define void @t5() nounwind {
|
|
entry:
|
|
; CHECK-LABEL: t5
|
|
; CHECK: mvn r0, #65280
|
|
call void @foo(i32 -65281)
|
|
ret void
|
|
}
|
|
|
|
define void @t6() nounwind {
|
|
entry:
|
|
; CHECK-LABEL: t6
|
|
; CHECK: mvn r0, #978944
|
|
call void @foo(i32 -978945)
|
|
ret void
|
|
}
|
|
|
|
define void @t7() nounwind {
|
|
entry:
|
|
; CHECK-LABEL: t7
|
|
; CHECK: mvn r0, #267386880
|
|
call void @foo(i32 -267386881)
|
|
ret void
|
|
}
|
|
|
|
define void @t8() nounwind {
|
|
entry:
|
|
; CHECK-LABEL: t8
|
|
; CHECK: mvn r0, #65280
|
|
call void @foo(i32 -65281)
|
|
ret void
|
|
}
|
|
|
|
define void @t9() nounwind {
|
|
entry:
|
|
; CHECK-LABEL: t9
|
|
; CHECK: mvn r0, #2130706432
|
|
call void @foo(i32 -2130706433)
|
|
ret void
|
|
}
|
|
|
|
; Load from constant pool.
|
|
define i32 @t10(i32 %a) {
|
|
; MOVT-LABEL: t10
|
|
; MOVT: ldr
|
|
%1 = xor i32 -1998730207, %a
|
|
ret i32 %1
|
|
}
|
|
|