summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorDiana Picus <diana.picus@linaro.org>2018-01-12 11:30:45 +0000
committerDiana Picus <diana.picus@linaro.org>2018-01-12 11:30:45 +0000
commite74243d4736efcecf794dd5693cd49864b2c5b03 (patch)
treecedc4ae6c7396c3ec69de03042f19460e609ee91 /llvm/test
parenta006baa620985e7974eda829c6bf6e3d63823b97 (diff)
downloadbcm5719-llvm-e74243d4736efcecf794dd5693cd49864b2c5b03.tar.gz
bcm5719-llvm-e74243d4736efcecf794dd5693cd49864b2c5b03.zip
[ARM GlobalISel] Legalize G_FMA
For hard float with VFP4, it is legal. Otherwise, we use libcalls. This needs a bit of support in the LegalizerHelper for soft float because we didn't handle G_FMA libcalls yet. The support is trivial, as the only difference between G_FMA and other libcalls that we already handle is that it has 3 input operands rather than just 2. llvm-svn: 322366
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/CodeGen/ARM/GlobalISel/arm-legalize-vfp4.mir121
1 files changed, 121 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/ARM/GlobalISel/arm-legalize-vfp4.mir b/llvm/test/CodeGen/ARM/GlobalISel/arm-legalize-vfp4.mir
new file mode 100644
index 00000000000..5fe0d86b2b4
--- /dev/null
+++ b/llvm/test/CodeGen/ARM/GlobalISel/arm-legalize-vfp4.mir
@@ -0,0 +1,121 @@
+# RUN: llc -mtriple arm-linux-gnueabihf -mattr=+vfp4 -float-abi=hard -global-isel -run-pass=legalizer %s -o - | FileCheck %s -check-prefix CHECK -check-prefix HARD
+# RUN: llc -mtriple arm-linux-gnueabihf -mattr=+vfp2 -float-abi=hard -global-isel -run-pass=legalizer %s -o - | FileCheck %s -check-prefix CHECK -check-prefix SOFT -check-prefix HARD-ABI
+# RUN: llc -mtriple arm-linux-gnueabi -mattr=+vfp4,+soft-float -float-abi=soft -global-isel -run-pass=legalizer %s -o - | FileCheck %s -check-prefix CHECK -check-prefix SOFT -check-prefix SOFT-ABI
+# RUN: llc -mtriple arm-linux-gnu -mattr=+vfp4,+soft-float -float-abi=soft -global-isel -run-pass=legalizer %s -o - | FileCheck %s -check-prefix CHECK -check-prefix SOFT -check-prefix SOFT-ABI
+--- |
+ define void @test_fma_float() { ret void }
+ define void @test_fma_double() { ret void }
+...
+---
+name: test_fma_float
+# CHECK-LABEL: name: test_fma_float
+legalized: false
+# CHECK: legalized: true
+regBankSelected: false
+selected: false
+tracksRegLiveness: true
+registers:
+ - { id: 0, class: _ }
+ - { id: 1, class: _ }
+ - { id: 2, class: _ }
+ - { id: 3, class: _ }
+body: |
+ bb.0:
+ liveins: %r0, %r1, %r2
+
+ ; CHECK-DAG: [[X:%[0-9]+]]:_(s32) = COPY %r0
+ ; CHECK-DAG: [[Y:%[0-9]+]]:_(s32) = COPY %r1
+ ; CHECK-DAG: [[Z:%[0-9]+]]:_(s32) = COPY %r2
+ %0(s32) = COPY %r0
+ %1(s32) = COPY %r1
+ %2(s32) = COPY %r2
+ ; HARD: [[R:%[0-9]+]]:_(s32) = G_FMA [[X]], [[Y]], [[Z]]
+ ; SOFT-NOT: G_FMA
+ ; SOFT: ADJCALLSTACKDOWN
+ ; SOFT-ABI-DAG: %r0 = COPY [[X]]
+ ; SOFT-ABI-DAG: %r1 = COPY [[Y]]
+ ; SOFT-ABI-DAG: %r2 = COPY [[Z]]
+ ; SOFT-ABI: BL &fmaf, {{.*}}, implicit %r0, implicit %r1, implicit %r2, implicit-def %r0
+ ; SOFT-ABI: [[R:%[0-9]+]]:_(s32) = COPY %r0
+ ; HARD-ABI-DAG: %s0 = COPY [[X]]
+ ; HARD-ABI-DAG: %s1 = COPY [[Y]]
+ ; HARD-ABI-DAG: %s2 = COPY [[Z]]
+ ; HARD-ABI: BL &fmaf, {{.*}}, implicit %s0, implicit %s1, implicit %s2, implicit-def %s0
+ ; HARD-ABI: [[R:%[0-9]+]]:_(s32) = COPY %s0
+ ; SOFT: ADJCALLSTACKUP
+ ; SOFT-NOT: G_FMA
+ %3(s32) = G_FMA %0, %1, %2
+ ; CHECK: %r0 = COPY [[R]]
+ %r0 = COPY %3(s32)
+ BX_RET 14, %noreg, implicit %r0
+...
+---
+name: test_fma_double
+# CHECK-LABEL: name: test_fma_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
+
+ ; 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
+ ; HARD-DAG: [[X:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[X0]]
+ ; HARD-DAG: [[Y:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[Y0]]
+ ; HARD-ABI-DAG: [[X:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[X0]]
+ ; HARD-ABI-DAG: [[Y:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[Y0]]
+ %4(s64) = G_MERGE_VALUES %0(s32), %1(s32)
+ %5(s64) = G_MERGE_VALUES %2(s32), %3(s32)
+ ; HARD: [[R:%[0-9]+]]:_(s64) = G_FMA [[X]], [[X]], [[Y]]
+ ; SOFT-NOT: G_FMA
+ ; SOFT: ADJCALLSTACKDOWN
+ ; SOFT-ABI-DAG: %r{{[0-1]}} = COPY [[X0]]
+ ; SOFT-ABI-DAG: %r{{[0-1]}} = COPY [[X1]]
+ ; SOFT-ABI-DAG: %r{{[2-3]}} = COPY [[X0]]
+ ; SOFT-ABI-DAG: %r{{[2-3]}} = COPY [[X1]]
+ ; SOFT-ABI: [[SP1:%[0-9]+]]:_(p0) = COPY %sp
+ ; SOFT-ABI: [[OFF1:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
+ ; SOFT-ABI: [[FI1:%[0-9]+]]:_(p0) = G_GEP [[SP1]], [[OFF1]](s32)
+ ; SOFT-ABI: G_STORE [[Y0]](s32), [[FI1]](p0){{.*}}store 8 into stack
+ ; SOFT-ABI: [[OFF2:%[0-9]+]]:_(s32) = G_CONSTANT i32 4
+ ; SOFT-ABI: [[FI2:%[0-9]+]]:_(p0) = G_GEP [[FI1]], [[OFF2]](s32)
+ ; SOFT-ABI: G_STORE [[Y1]](s32), [[FI2]](p0){{.*}}store 8 into stack
+ ; SOFT-ABI: BL &fma, {{.*}}, implicit %r0, implicit %r1, implicit %r2, implicit %r3, implicit-def %r0, implicit-def %r1
+ ; SOFT-ABI-DAG: [[R0:%[0-9]+]]:_(s32) = COPY %r0
+ ; SOFT-ABI-DAG: [[R1:%[0-9]+]]:_(s32) = COPY %r1
+ ; HARD-ABI-DAG: %d0 = COPY [[X]]
+ ; HARD-ABI-DAG: %d1 = COPY [[X]]
+ ; HARD-ABI-DAG: %d2 = COPY [[Y]]
+ ; HARD-ABI: BL &fma, {{.*}}, implicit %d0, implicit %d1, implicit %d2, implicit-def %d0
+ ; HARD-ABI: [[R:%[0-9]+]]:_(s64) = COPY %d0
+ ; SOFT: ADJCALLSTACKUP
+ ; SOFT-NOT: G_FMA
+ %6(s64) = G_FMA %4, %4, %5
+ ; HARD: [[R0:%[0-9]+]]:_(s32), [[R1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[R]](s64)
+ ; HARD-ABI: [[R0:%[0-9]+]]:_(s32), [[R1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[R]](s64)
+ %7(s32),%8(s32) = G_UNMERGE_VALUES %6(s64)
+ ; CHECK-DAG: %r0 = COPY [[R0]]
+ ; CHECK-DAG: %r1 = COPY [[R1]]
+ %r0 = COPY %7(s32)
+ %r1 = COPY %8(s32)
+ BX_RET 14, %noreg, implicit %r0, implicit %r1
+...
OpenPOWER on IntegriCloud