AMDGPU/GlobalISel: Mark 32/64-bit G_FCMP as legal
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Thu, 1 Mar 2018 19:09:16 +0000 (19:09 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Thu, 1 Mar 2018 19:09:16 +0000 (19:09 +0000)
Patch by Tom Stellard

llvm-svn: 326465

llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-fcmp.mir [new file with mode: 0644]

index 7c6926d..269aac6 100644 (file)
@@ -54,6 +54,10 @@ AMDGPULegalizerInfo::AMDGPULegalizerInfo() {
 
   setAction({G_FADD, S32}, Legal);
 
+  setAction({G_FCMP, S1}, Legal);
+  setAction({G_FCMP, 1, S32}, Legal);
+  setAction({G_FCMP, 1, S64}, Legal);
+
   setAction({G_FMUL, S32}, Legal);
 
   setAction({G_FPTOSI, S32}, Legal);
diff --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-fcmp.mir b/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-fcmp.mir
new file mode 100644 (file)
index 0000000..0f2370c
--- /dev/null
@@ -0,0 +1,35 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -march=amdgcn -mcpu=fiji  -run-pass=legalizer -global-isel %s -o - | FileCheck %s
+
+---
+name: test_fcmp_f32
+registers:
+  - { id: 0, class: _ }
+  - { id: 1, class: _ }
+  - { id: 2, class: _ }
+body: |
+  bb.0:
+    liveins: $vgpr0
+    ; CHECK-LABEL: name: test_fcmp_f32
+    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
+    %0(s32) = G_CONSTANT i32 0
+    %1(s32) = COPY $vgpr0
+
+    %2(s1) = G_FCMP floatpred(uge), %0, %1
+...
+---
+name: test_fcmp_f64
+registers:
+  - { id: 0, class: _ }
+  - { id: 1, class: _ }
+  - { id: 2, class: _ }
+body: |
+  bb.0:
+    liveins: $vgpr0_vgpr1
+    ; CHECK-LABEL: name: test_fcmp_f64
+    ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $vgpr0_vgpr1
+    %0(s64) = G_CONSTANT i64 0
+    %1(s64) = COPY $vgpr0_vgpr1
+
+    %2(s1) = G_FCMP floatpred(uge), %0, %1
+...