[ARM] GlobalISel: Support frem for 64-bit values

Legalize to a libcall.

llvm-svn: 299756
This commit is contained in:
Diana Picus 2017-04-07 10:50:02 +00:00
parent 9d9a663731
commit 3c608448e1
3 changed files with 59 additions and 0 deletions

View File

@ -66,6 +66,7 @@ ARMLegalizerInfo::ARMLegalizerInfo(const ARMSubtarget &ST) {
}
setAction({G_FREM, s32}, Libcall);
setAction({G_FREM, s64}, Libcall);
computeTables();
}

View File

@ -9,3 +9,9 @@ define arm_aapcscc float @test_frem_float(float %x, float %y) {
ret float %r
}
define arm_aapcscc double @test_frem_double(double %x, double %y) {
; CHECK-LABEL: test_frem_double:
; CHECK: blx fmod
%r = frem double %x, %y
ret double %r
}

View File

@ -3,6 +3,7 @@
# RUN: llc -mtriple arm-- -float-abi=soft -global-isel -run-pass=legalizer %s -o - | FileCheck %s
--- |
define void @test_frem_float() { ret void }
define void @test_frem_double() { ret void }
...
---
name: test_frem_float
@ -35,3 +36,54 @@ body: |
%r0 = COPY %2(s32)
BX_RET 14, _, implicit %r0
...
---
name: test_frem_double
# CHECK-LABEL: name: test_frem_double
legalized: false
# CHECK: legalized: true
regBankSelected: false
selected: false
tracksRegLiveness: true
registers:
- { id: 0, class: _ }
- { id: 1, class: _ }
- { id: 2, class: _ }
- { id: 3, class: _ }
- { id: 4, class: _ }
- { id: 5, class: _ }
- { id: 6, class: _ }
- { id: 7, class: _ }
- { id: 8, class: _ }
body: |
bb.0:
liveins: %r0, %r1, %r2, %r3
; The inputs may be in the wrong order (depending on the target's
; endianness), but that's orthogonal to what we're trying to test here. We
; only need to check that the first value, received through R0-R1, ends up
; in R0-R1 or R1-R0, and the second value, received through R2-R3, ends up
; in R2-R3 or R3-R2, when passed to fmod.
; CHECK-DAG: [[X0:%[0-9]+]](s32) = COPY %r0
; CHECK-DAG: [[X1:%[0-9]+]](s32) = COPY %r1
; CHECK-DAG: [[Y0:%[0-9]+]](s32) = COPY %r2
; CHECK-DAG: [[Y1:%[0-9]+]](s32) = COPY %r3
%0(s32) = COPY %r0
%1(s32) = COPY %r1
%2(s32) = COPY %r2
%3(s32) = COPY %r3
%4(s64) = G_SEQUENCE %0(s32), 0, %1(s32), 32
%5(s64) = G_SEQUENCE %2(s32), 0, %3(s32), 32
; CHECK: ADJCALLSTACKDOWN
; CHECK-DAG: %r{{[0-1]}} = COPY [[X0]]
; CHECK-DAG: %r{{[0-1]}} = COPY [[X1]]
; CHECK-DAG: %r{{[2-3]}} = COPY [[Y0]]
; CHECK-DAG: %r{{[2-3]}} = COPY [[Y1]]
; CHECK: BLX $fmod, {{.*}}, implicit %r0, implicit %r1, implicit %r2, implicit %r3, implicit-def %r0, implicit-def %r1
; CHECK: ADJCALLSTACKUP
%6(s64) = G_FREM %4, %5
%7(s32) = G_EXTRACT %6(s64), 0
%8(s32) = G_EXTRACT %6(s64), 32
%r0 = COPY %7(s32)
%r1 = COPY %8(s32)
BX_RET 14, _, implicit %r0, implicit %r1
...