]> granicus.if.org Git - llvm/commitdiff
AMDGPU/GlobalISel: Legalize more fp<->int conversions
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Tue, 22 Jan 2019 00:20:17 +0000 (00:20 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Tue, 22 Jan 2019 00:20:17 +0000 (00:20 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351767 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
test/CodeGen/AMDGPU/GlobalISel/legalize-fptosi.mir
test/CodeGen/AMDGPU/GlobalISel/legalize-fptoui.mir
test/CodeGen/AMDGPU/GlobalISel/legalize-sitofp.mir
test/CodeGen/AMDGPU/GlobalISel/legalize-uitofp.mir [new file with mode: 0644]

index a8e12d06c0aea27755d8b9710dce3e6c8b633caf..3d7a32af6e743da616839c703f6e1053ae24d013 100644 (file)
@@ -163,17 +163,11 @@ AMDGPULegalizerInfo::AMDGPULegalizerInfo(const GCNSubtarget &ST,
     .legalFor({{S64, S32}, {S32, S16}, {S64, S16},
                {S32, S1}, {S64, S1}, {S16, S1}});
 
-  setAction({G_FPTOSI, S32}, Legal);
-  setAction({G_FPTOSI, 1, S32}, Legal);
+  getActionDefinitionsBuilder({G_SITOFP, G_UITOFP})
+    .legalFor({{S32, S32}, {S64, S32}});
 
-  setAction({G_SITOFP, S32}, Legal);
-  setAction({G_SITOFP, 1, S32}, Legal);
-
-  setAction({G_UITOFP, S32}, Legal);
-  setAction({G_UITOFP, 1, S32}, Legal);
-
-  setAction({G_FPTOUI, S32}, Legal);
-  setAction({G_FPTOUI, 1, S32}, Legal);
+  getActionDefinitionsBuilder({G_FPTOSI, G_FPTOUI})
+    .legalFor({{S32, S32}, {S32, S64}});
 
   setAction({G_FPOW, S32}, Legal);
   setAction({G_FEXP2, S32}, Legal);
index d4414bc62f0e0742b97db9eb396728fa794315e3..60c2e2aecaaf6c035ebd6bfe16ee2c733b0ab9f5 100644 (file)
@@ -2,13 +2,25 @@
 # RUN: llc -mtriple=amdgcn-mesa-mesa3d -mcpu=fiji -run-pass=legalizer %s -o - | FileCheck %s
 
 ---
-name: test_fptosi_f32_to_i32
+name: test_fptosi_s32_to_s32
 body: |
   bb.0:
     liveins: $vgpr0
 
-    ; CHECK-LABEL: name: test_fptosi_f32_to_i32
+    ; CHECK-LABEL: name: test_fptosi_s32_to_s32
     ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
     %0:_(s32) = COPY $vgpr0
     %1:_(s32) = G_FPTOSI %0
 ...
+
+---
+name: test_fptosi_s64_to_s32
+body: |
+  bb.0:
+    liveins: $vgpr0_vgpr1
+
+    ; CHECK-LABEL: name: test_fptosi_s64_to_s32
+    ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $vgpr0_vgpr1
+    %0:_(s64) = COPY $vgpr0_vgpr1
+    %1:_(s32) = G_FPTOSI %0
+...
index aede6af2603590517f71fe17103590369c327e49..c77b8ed21514440af4be9b513b58e53f0263fb74 100644 (file)
@@ -1,14 +1,33 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
 # RUN: llc -mtriple=amdgcn-mesa-mesa3d -run-pass=legalizer %s -o - | FileCheck %s
 
 ---
-name:            test_fptoui
+name: test_fptoui_s32_s32
 body: |
   bb.0:
     liveins: $vgpr0
-    ; CHECK-LABEL: name: test_fptoui
-    ; CHECK: %1:_(s32) = G_FPTOUI %0
 
+    ; CHECK-LABEL: name: test_fptoui_s32_s32
+    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
+    ; CHECK: [[FPTOUI:%[0-9]+]]:_(s32) = G_FPTOUI [[COPY]](s32)
+    ; CHECK: $vgpr0 = COPY [[FPTOUI]](s32)
     %0:_(s32) = COPY $vgpr0
     %1:_(s32) = G_FPTOUI %0
     $vgpr0 = COPY %1
 ...
+
+---
+name: test_fptoui_s32_s64
+body: |
+  bb.0:
+    liveins: $vgpr0_vgpr1
+
+    ; CHECK-LABEL: name: test_fptoui_s32_s64
+    ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $vgpr0_vgpr1
+    ; CHECK: [[FPTOUI:%[0-9]+]]:_(s32) = G_FPTOUI [[COPY]](s64)
+    ; CHECK: $vgpr0 = COPY [[FPTOUI]](s32)
+    %0:_(s64) = COPY $vgpr0_vgpr1
+    %1:_(s32) = G_FPTOUI %0
+    $vgpr0 = COPY %1
+...
+
index 649f8903cd1c291830ef47682d14aefa4749d4a8..aa86c5f0253370db55e4c658c89a971bb2f67060 100644 (file)
@@ -2,13 +2,32 @@
 # RUN: llc -mtriple=amdgcn-mesa-mesa3d -mcpu=fiji -run-pass=legalizer -global-isel %s -o - | FileCheck %s
 
 ---
-name: test_sitofp_f32_to_i32
+name: test_sitofp_s32_to_s32
 body: |
   bb.0:
     liveins: $vgpr0
 
-    ; CHECK-LABEL: name: test_sitofp_f32_to_i32
+    ; CHECK-LABEL: name: test_sitofp_s32_to_s32
     ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
+    ; CHECK: [[SITOFP:%[0-9]+]]:_(s32) = G_SITOFP [[COPY]](s32)
+    ; CHECK: $vgpr0 = COPY [[SITOFP]](s32)
     %0:_(s32) = COPY $vgpr0
     %1:_(s32) = G_SITOFP %0
+    $vgpr0 = COPY %1
 ...
+
+---
+name: test_sitofp_s32_to_s64
+body: |
+  bb.0:
+    liveins: $vgpr0
+
+    ; CHECK-LABEL: name: test_sitofp_s32_to_s64
+    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
+    ; CHECK: [[SITOFP:%[0-9]+]]:_(s64) = G_SITOFP [[COPY]](s32)
+    ; CHECK: $vgpr0_vgpr1 = COPY [[SITOFP]](s64)
+    %0:_(s32) = COPY $vgpr0
+    %1:_(s64) = G_SITOFP %0
+    $vgpr0_vgpr1 = COPY %1
+...
+
diff --git a/test/CodeGen/AMDGPU/GlobalISel/legalize-uitofp.mir b/test/CodeGen/AMDGPU/GlobalISel/legalize-uitofp.mir
new file mode 100644 (file)
index 0000000..f376054
--- /dev/null
@@ -0,0 +1,33 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -mtriple=amdgcn-mesa-mesa3d -mcpu=fiji -run-pass=legalizer -global-isel %s -o - | FileCheck %s
+
+---
+name: test_uitofp_s32_to_s32
+body: |
+  bb.0:
+    liveins: $vgpr0
+
+    ; CHECK-LABEL: name: test_uitofp_s32_to_s32
+    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
+    ; CHECK: [[UITOFP:%[0-9]+]]:_(s32) = G_UITOFP [[COPY]](s32)
+    ; CHECK: $vgpr0 = COPY [[UITOFP]](s32)
+    %0:_(s32) = COPY $vgpr0
+    %1:_(s32) = G_UITOFP %0
+    $vgpr0 = COPY %1
+...
+
+---
+name: test_uitofp_s32_to_s64
+body: |
+  bb.0:
+    liveins: $vgpr0
+
+    ; CHECK-LABEL: name: test_uitofp_s32_to_s64
+    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
+    ; CHECK: [[UITOFP:%[0-9]+]]:_(s64) = G_UITOFP [[COPY]](s32)
+    ; CHECK: $vgpr0_vgpr1 = COPY [[UITOFP]](s64)
+    %0:_(s32) = COPY $vgpr0
+    %1:_(s64) = G_UITOFP %0
+    $vgpr0_vgpr1 = COPY %1
+...
+