[PATCH] D54718: Restored selection of scalar_to_vector (v2x16)

Stanislav Mekhanoshin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 19 11:58:39 PST 2018


rampitec created this revision.
rampitec added reviewers: arsenm, kzhuravl, scott.linder.
Herald added subscribers: nhaehnle, wdng, jvesely.

This works if DAG combiner is enabled, but without combining
we cannot select scalar_to_vector of <2 x half> and <2 x i16>.


https://reviews.llvm.org/D54718

Files:
  lib/Target/AMDGPU/SIInstructions.td
  test/CodeGen/AMDGPU/scalar_to_vector_v2x16.ll


Index: test/CodeGen/AMDGPU/scalar_to_vector_v2x16.ll
===================================================================
--- /dev/null
+++ test/CodeGen/AMDGPU/scalar_to_vector_v2x16.ll
@@ -0,0 +1,26 @@
+; RUN: llc -march=amdgcn -mcpu=fiji -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GCN,GCN-OPT %s
+; RUN: llc -march=amdgcn -mcpu=fiji -O0 -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GCN,GCN-NOOPT %s
+
+; GCN-LABEL: {{^}}scalar_to_vector_i16:
+; GCN-NOOPT: s_mov_b32 [[S:s[0-9]+]], 42
+; GCN-NOOPT: v_mov_b32_e32 [[V:v[0-9]+]], [[S]]
+; GCN-OPT:   v_mov_b32_e32 [[V:v[0-9]+]], 42
+; GCN: buffer_store_short [[V]],
+define void @scalar_to_vector_i16() {
+  %tmp = load <2 x i16>, <2 x i16> addrspace(5)* undef
+  %tmp1 = insertelement <2 x i16> %tmp, i16 42, i64 0
+  store <2 x i16> %tmp1, <2 x i16> addrspace(5)* undef
+  ret void
+}
+
+; GCN-LABEL: {{^}}scalar_to_vector_f16:
+; GCN-NOOPT: s_movk_i32 [[S:s[0-9]+]], 0x3c00
+; GCN-NOOPT: v_mov_b32_e32 [[V:v[0-9]+]], [[S]]
+; GCN-OPT:   v_mov_b32_e32 [[V:v[0-9]+]], 0x3c00
+; GCN: buffer_store_short [[V]],
+define void @scalar_to_vector_f16() {
+  %tmp = load <2 x half>, <2 x half> addrspace(5)* undef
+  %tmp1 = insertelement <2 x half> %tmp, half 1.0, i64 0
+  store <2 x half> %tmp1, <2 x half> addrspace(5)* undef
+  ret void
+}
Index: lib/Target/AMDGPU/SIInstructions.td
===================================================================
--- lib/Target/AMDGPU/SIInstructions.td
+++ lib/Target/AMDGPU/SIInstructions.td
@@ -1537,15 +1537,15 @@
 } // End SubtargetPredicate = HasVOP3PInsts
 
 
-// def : GCNPat <
-//   (v2f16 (scalar_to_vector f16:$src0)),
-//   (COPY $src0)
-// >;
-
-// def : GCNPat <
-//   (v2i16 (scalar_to_vector i16:$src0)),
-//   (COPY $src0)
-// >;
+def : GCNPat <
+  (v2f16 (scalar_to_vector f16:$src0)),
+  (COPY $src0)
+>;
+
+def : GCNPat <
+  (v2i16 (scalar_to_vector i16:$src0)),
+  (COPY $src0)
+>;
 
 def : GCNPat <
   (v4i16 (scalar_to_vector i16:$src0)),


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54718.174661.patch
Type: text/x-patch
Size: 2003 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181119/a0021452/attachment.bin>


More information about the llvm-commits mailing list