GlobalISel: Add DAG compat for G_FCANONICALIZE
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Mon, 1 Jul 2019 13:22:00 +0000 (13:22 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Mon, 1 Jul 2019 13:22:00 +0000 (13:22 +0000)
llvm-svn: 364758

llvm/include/llvm/Target/GlobalISel/SelectionDAGCompat.td
llvm/test/CodeGen/AMDGPU/GlobalISel/inst-select-fcanonicalize.mir [new file with mode: 0644]

index d355c94..5b49544 100644 (file)
@@ -76,6 +76,7 @@ def : GINodeEquiv<G_FREM, frem>;
 def : GINodeEquiv<G_FPOW, fpow>;
 def : GINodeEquiv<G_FEXP2, fexp2>;
 def : GINodeEquiv<G_FLOG2, flog2>;
+def : GINodeEquiv<G_FCANONICALIZE, fcanonicalize>;
 def : GINodeEquiv<G_INTRINSIC, intrinsic_wo_chain>;
 // ISD::INTRINSIC_VOID can also be handled with G_INTRINSIC_W_SIDE_EFFECTS.
 def : GINodeEquiv<G_INTRINSIC_W_SIDE_EFFECTS, intrinsic_void>;
diff --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/inst-select-fcanonicalize.mir b/llvm/test/CodeGen/AMDGPU/GlobalISel/inst-select-fcanonicalize.mir
new file mode 100644 (file)
index 0000000..45489b1
--- /dev/null
@@ -0,0 +1,169 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -march=amdgcn -mcpu=gfx900 -mattr=+fp32-denormals,+fp64-fp16-denormals -run-pass=instruction-select -global-isel-abort=2 -verify-machineinstrs -o - %s | FileCheck -check-prefix=GFX9-DENORM %s
+# RUN: llc -march=amdgcn -mcpu=gfx900 -mattr=-fp32-denormals,-fp64-fp16-denormals -run-pass=instruction-select -global-isel-abort=2 -verify-machineinstrs -o - %s | FileCheck -check-prefix=GFX9-FLUSH %s
+
+---
+
+name:            fcanonicalize_f16
+legalized:       true
+regBankSelected: true
+
+body: |
+  bb.0:
+    liveins: $vgpr0
+    ; GFX9-DENORM-LABEL: name: fcanonicalize_f16
+    ; GFX9-DENORM: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
+    ; GFX9-DENORM: [[V_MAX_F16_e64_:%[0-9]+]]:vgpr_32 = V_MAX_F16_e64 0, [[COPY]], 0, [[COPY]], 0, 0, implicit $exec
+    ; GFX9-DENORM: S_ENDPGM 0, implicit [[V_MAX_F16_e64_]]
+    ; GFX9-FLUSH-LABEL: name: fcanonicalize_f16
+    ; GFX9-FLUSH: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
+    ; GFX9-FLUSH: [[V_MUL_F16_e64_:%[0-9]+]]:vgpr_32 = V_MUL_F16_e64 0, 15360, 0, [[COPY]], 0, 0, implicit $exec
+    ; GFX9-FLUSH: S_ENDPGM 0, implicit [[V_MUL_F16_e64_]]
+    %0:vgpr(s32) = COPY $vgpr0
+    %1:vgpr(s16) = G_TRUNC %0
+    %2:vgpr(s16) = G_FCANONICALIZE %1
+    S_ENDPGM 0, implicit %2
+...
+
+---
+
+name:            fcanonicalize_f32
+legalized:       true
+regBankSelected: true
+
+body: |
+  bb.0:
+    liveins: $vgpr0
+    ; GFX9-DENORM-LABEL: name: fcanonicalize_f32
+    ; GFX9-DENORM: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
+    ; GFX9-DENORM: [[V_MAX_F32_e64_:%[0-9]+]]:vgpr_32 = V_MAX_F32_e64 0, [[COPY]], 0, [[COPY]], 0, 0, implicit $exec
+    ; GFX9-DENORM: S_ENDPGM 0, implicit [[V_MAX_F32_e64_]]
+    ; GFX9-FLUSH-LABEL: name: fcanonicalize_f32
+    ; GFX9-FLUSH: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
+    ; GFX9-FLUSH: [[V_MUL_F32_e64_:%[0-9]+]]:vgpr_32 = V_MUL_F32_e64 0, 1065353216, 0, [[COPY]], 0, 0, implicit $exec
+    ; GFX9-FLUSH: S_ENDPGM 0, implicit [[V_MUL_F32_e64_]]
+    %0:vgpr(s32) = COPY $vgpr0
+    %1:vgpr(s32) = G_FCANONICALIZE %0
+    S_ENDPGM 0, implicit %1
+...
+
+---
+
+name:            fcanonicalize_v2f16
+legalized:       true
+regBankSelected: true
+
+body: |
+  bb.0:
+    liveins: $vgpr0
+    ; GFX9-DENORM-LABEL: name: fcanonicalize_v2f16
+    ; GFX9-DENORM: [[COPY:%[0-9]+]]:vgpr(<2 x s16>) = COPY $vgpr0
+    ; GFX9-DENORM: [[FCANONICALIZE:%[0-9]+]]:vgpr(<2 x s16>) = G_FCANONICALIZE [[COPY]]
+    ; GFX9-DENORM: S_ENDPGM 0, implicit [[FCANONICALIZE]](<2 x s16>)
+    ; GFX9-FLUSH-LABEL: name: fcanonicalize_v2f16
+    ; GFX9-FLUSH: [[COPY:%[0-9]+]]:vgpr(<2 x s16>) = COPY $vgpr0
+    ; GFX9-FLUSH: [[FCANONICALIZE:%[0-9]+]]:vgpr(<2 x s16>) = G_FCANONICALIZE [[COPY]]
+    ; GFX9-FLUSH: S_ENDPGM 0, implicit [[FCANONICALIZE]](<2 x s16>)
+    %0:vgpr(<2 x s16>) = COPY $vgpr0
+    %1:vgpr(<2 x s16>) = G_FCANONICALIZE %0
+    S_ENDPGM 0, implicit %1
+...
+
+---
+
+name:            fcanonicalize_f64
+legalized:       true
+regBankSelected: true
+
+body: |
+  bb.0:
+    liveins: $vgpr0_vgpr1
+    ; GFX9-DENORM-LABEL: name: fcanonicalize_f64
+    ; GFX9-DENORM: [[COPY:%[0-9]+]]:vreg_64 = COPY $vgpr0_vgpr1
+    ; GFX9-DENORM: [[V_MAX_F64_:%[0-9]+]]:vreg_64 = V_MAX_F64 0, [[COPY]], 0, [[COPY]], 0, 0, implicit $exec
+    ; GFX9-DENORM: S_ENDPGM 0, implicit [[V_MAX_F64_]]
+    ; GFX9-FLUSH-LABEL: name: fcanonicalize_f64
+    ; GFX9-FLUSH: [[COPY:%[0-9]+]]:vreg_64 = COPY $vgpr0_vgpr1
+    ; GFX9-FLUSH: [[V_MUL_F64_:%[0-9]+]]:vreg_64 = V_MUL_F64 0, 4607182418800017408, 0, [[COPY]], 0, 0, implicit $exec
+    ; GFX9-FLUSH: S_ENDPGM 0, implicit [[V_MUL_F64_]]
+    %0:vgpr(s64) = COPY $vgpr0_vgpr1
+    %1:vgpr(s64) = G_FCANONICALIZE %0
+    S_ENDPGM 0, implicit %1
+...
+
+---
+
+name:            fcanonicalize_fabs_f32
+legalized:       true
+regBankSelected: true
+
+body: |
+  bb.0:
+    liveins: $vgpr0
+    ; GFX9-DENORM-LABEL: name: fcanonicalize_fabs_f32
+    ; GFX9-DENORM: [[COPY:%[0-9]+]]:vgpr(s32) = COPY $vgpr0
+    ; GFX9-DENORM: [[FABS:%[0-9]+]]:vgpr_32(s32) = G_FABS [[COPY]]
+    ; GFX9-DENORM: [[V_MAX_F32_e64_:%[0-9]+]]:vgpr_32(s32) = V_MAX_F32_e64 0, [[FABS]](s32), 0, [[FABS]](s32), 0, 0, implicit $exec
+    ; GFX9-DENORM: S_ENDPGM 0, implicit [[V_MAX_F32_e64_]](s32)
+    ; GFX9-FLUSH-LABEL: name: fcanonicalize_fabs_f32
+    ; GFX9-FLUSH: [[COPY:%[0-9]+]]:vgpr(s32) = COPY $vgpr0
+    ; GFX9-FLUSH: [[FABS:%[0-9]+]]:vgpr_32(s32) = G_FABS [[COPY]]
+    ; GFX9-FLUSH: [[V_MUL_F32_e64_:%[0-9]+]]:vgpr_32(s32) = V_MUL_F32_e64 0, 1065353216, 0, [[FABS]](s32), 0, 0, implicit $exec
+    ; GFX9-FLUSH: S_ENDPGM 0, implicit [[V_MUL_F32_e64_]](s32)
+    %0:vgpr(s32) = COPY $vgpr0
+    %1:vgpr(s32) = G_FABS %0
+    %2:vgpr(s32) = G_FCANONICALIZE %1
+    S_ENDPGM 0, implicit %2
+...
+
+---
+
+name:            fcanonicalize_fneg_f32
+legalized:       true
+regBankSelected: true
+
+body: |
+  bb.0:
+    liveins: $vgpr0
+    ; GFX9-DENORM-LABEL: name: fcanonicalize_fneg_f32
+    ; GFX9-DENORM: [[COPY:%[0-9]+]]:vgpr(s32) = COPY $vgpr0
+    ; GFX9-DENORM: [[FNEG:%[0-9]+]]:vgpr_32(s32) = G_FNEG [[COPY]]
+    ; GFX9-DENORM: [[V_MAX_F32_e64_:%[0-9]+]]:vgpr_32(s32) = V_MAX_F32_e64 0, [[FNEG]](s32), 0, [[FNEG]](s32), 0, 0, implicit $exec
+    ; GFX9-DENORM: S_ENDPGM 0, implicit [[V_MAX_F32_e64_]](s32)
+    ; GFX9-FLUSH-LABEL: name: fcanonicalize_fneg_f32
+    ; GFX9-FLUSH: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
+    ; GFX9-FLUSH: [[V_MUL_F32_e64_:%[0-9]+]]:vgpr_32 = V_MUL_F32_e64 0, 3212836864, 0, [[COPY]], 0, 0, implicit $exec
+    ; GFX9-FLUSH: S_ENDPGM 0, implicit [[V_MUL_F32_e64_]]
+    %0:vgpr(s32) = COPY $vgpr0
+    %1:vgpr(s32) = G_FNEG %0
+    %2:vgpr(s32) = G_FCANONICALIZE %1
+    S_ENDPGM 0, implicit %2
+...
+
+---
+
+name:            fcanonicalize_fneg_fabs_f32
+legalized:       true
+regBankSelected: true
+
+body: |
+  bb.0:
+    liveins: $vgpr0
+    ; GFX9-DENORM-LABEL: name: fcanonicalize_fneg_fabs_f32
+    ; GFX9-DENORM: [[COPY:%[0-9]+]]:vgpr(s32) = COPY $vgpr0
+    ; GFX9-DENORM: [[FNEG:%[0-9]+]]:vgpr(s32) = G_FNEG [[COPY]]
+    ; GFX9-DENORM: [[FABS:%[0-9]+]]:vgpr_32(s32) = G_FABS [[FNEG]]
+    ; GFX9-DENORM: [[V_MAX_F32_e64_:%[0-9]+]]:vgpr_32(s32) = V_MAX_F32_e64 0, [[FABS]](s32), 0, [[FABS]](s32), 0, 0, implicit $exec
+    ; GFX9-DENORM: S_ENDPGM 0, implicit [[V_MAX_F32_e64_]](s32)
+    ; GFX9-FLUSH-LABEL: name: fcanonicalize_fneg_fabs_f32
+    ; GFX9-FLUSH: [[COPY:%[0-9]+]]:vgpr(s32) = COPY $vgpr0
+    ; GFX9-FLUSH: [[FNEG:%[0-9]+]]:vgpr(s32) = G_FNEG [[COPY]]
+    ; GFX9-FLUSH: [[FABS:%[0-9]+]]:vgpr_32(s32) = G_FABS [[FNEG]]
+    ; GFX9-FLUSH: [[V_MUL_F32_e64_:%[0-9]+]]:vgpr_32(s32) = V_MUL_F32_e64 0, 1065353216, 0, [[FABS]](s32), 0, 0, implicit $exec
+    ; GFX9-FLUSH: S_ENDPGM 0, implicit [[V_MUL_F32_e64_]](s32)
+    %0:vgpr(s32) = COPY $vgpr0
+    %1:vgpr(s32) = G_FNEG %0
+    %2:vgpr(s32) = G_FABS %1
+    %3:vgpr(s32) = G_FCANONICALIZE %2
+    S_ENDPGM 0, implicit %3
+...