mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-21 00:32:23 +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
101 lines
2.5 KiB
LLVM
101 lines
2.5 KiB
LLVM
; RUN: llc < %s -O0 -verify-machineinstrs -fast-isel-abort -relocation-model=dynamic-no-pic -mtriple=armv7-apple-ios | FileCheck %s --check-prefix=ARM
|
|
; RUN: llc < %s -O0 -verify-machineinstrs -fast-isel-abort -relocation-model=dynamic-no-pic -mtriple=armv7-linux-gnueabi | FileCheck %s --check-prefix=ARM
|
|
; RUN: llc < %s -O0 -verify-machineinstrs -fast-isel-abort -relocation-model=dynamic-no-pic -mtriple=thumbv7-apple-ios | FileCheck %s --check-prefix=THUMB
|
|
; RUN: llc < %s -O0 -fast-isel-abort -relocation-model=dynamic-no-pic -mtriple=thumbv8-apple-ios | FileCheck %s --check-prefix=THUMB
|
|
|
|
define i32 @t1(i1 %c) nounwind readnone {
|
|
entry:
|
|
; ARM: t1
|
|
; ARM: movw r{{[1-9]}}, #10
|
|
; ARM: cmp r0, #0
|
|
; ARM: moveq r{{[1-9]}}, #20
|
|
; ARM: mov r0, r{{[1-9]}}
|
|
; THUMB: t1
|
|
; THUMB: movs r{{[1-9]}}, #10
|
|
; THUMB: cmp r0, #0
|
|
; THUMB: it eq
|
|
; THUMB: moveq r{{[1-9]}}, #20
|
|
; THUMB: mov r0, r{{[1-9]}}
|
|
%0 = select i1 %c, i32 10, i32 20
|
|
ret i32 %0
|
|
}
|
|
|
|
define i32 @t2(i1 %c, i32 %a) nounwind readnone {
|
|
entry:
|
|
; ARM: t2
|
|
; ARM: cmp r0, #0
|
|
; ARM: moveq r{{[1-9]}}, #20
|
|
; ARM: mov r0, r{{[1-9]}}
|
|
; THUMB: t2
|
|
; THUMB: cmp r0, #0
|
|
; THUMB: it eq
|
|
; THUMB: moveq r{{[1-9]}}, #20
|
|
; THUMB: mov r0, r{{[1-9]}}
|
|
%0 = select i1 %c, i32 %a, i32 20
|
|
ret i32 %0
|
|
}
|
|
|
|
define i32 @t3(i1 %c, i32 %a, i32 %b) nounwind readnone {
|
|
entry:
|
|
; ARM: t3
|
|
; ARM: cmp r0, #0
|
|
; ARM: movne r2, r1
|
|
; ARM: add r0, r2, r1
|
|
; THUMB: t3
|
|
; THUMB: cmp r0, #0
|
|
; THUMB: it ne
|
|
; THUMB: movne r2, r1
|
|
; THUMB: add.w r0, r2, r1
|
|
%0 = select i1 %c, i32 %a, i32 %b
|
|
%1 = add i32 %0, %a
|
|
ret i32 %1
|
|
}
|
|
|
|
define i32 @t4(i1 %c) nounwind readnone {
|
|
entry:
|
|
; ARM: t4
|
|
; ARM: mvn r{{[1-9]}}, #9
|
|
; ARM: cmp r0, #0
|
|
; ARM: mvneq r{{[1-9]}}, #0
|
|
; ARM: mov r0, r{{[1-9]}}
|
|
; THUMB-LABEL: t4
|
|
; THUMB: mvn [[REG:r[1-9]+]], #9
|
|
; THUMB: cmp r0, #0
|
|
; THUMB: it eq
|
|
; THUMB: mvneq [[REG]], #0
|
|
; THUMB: mov r0, [[REG]]
|
|
%0 = select i1 %c, i32 -10, i32 -1
|
|
ret i32 %0
|
|
}
|
|
|
|
define i32 @t5(i1 %c, i32 %a) nounwind readnone {
|
|
entry:
|
|
; ARM: t5
|
|
; ARM: cmp r0, #0
|
|
; ARM: mvneq r{{[1-9]}}, #1
|
|
; ARM: mov r0, r{{[1-9]}}
|
|
; THUMB: t5
|
|
; THUMB: cmp r0, #0
|
|
; THUMB: it eq
|
|
; THUMB: mvneq r{{[1-9]}}, #1
|
|
; THUMB: mov r0, r{{[1-9]}}
|
|
%0 = select i1 %c, i32 %a, i32 -2
|
|
ret i32 %0
|
|
}
|
|
|
|
; Check one large negative immediates.
|
|
define i32 @t6(i1 %c, i32 %a) nounwind readnone {
|
|
entry:
|
|
; ARM: t6
|
|
; ARM: cmp r0, #0
|
|
; ARM: mvneq r{{[1-9]}}, #978944
|
|
; ARM: mov r0, r{{[1-9]}}
|
|
; THUMB: t6
|
|
; THUMB: cmp r0, #0
|
|
; THUMB: it eq
|
|
; THUMB: mvneq r{{[1-9]}}, #978944
|
|
; THUMB: mov r0, r{{[1-9]}}
|
|
%0 = select i1 %c, i32 %a, i32 -978945
|
|
ret i32 %0
|
|
}
|