This is an archive of the discontinued LLVM Phabricator instance.

[X86][FP16] Avoid to generate VZEXT_MOVL with i16
ClosedPublic

Authored by pengfei on Nov 11 2021, 3:32 AM.

Details

Summary

This fixes the crash due to lacking VZEXT_MOVL support with i16.

Diff Detail

Event Timeline

pengfei created this revision.Nov 11 2021, 3:32 AM
pengfei requested review of this revision.Nov 11 2021, 3:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 11 2021, 3:32 AM
pengfei updated this revision to Diff 386472.Nov 11 2021, 3:43 AM

Swapped the condition order.

RKSimon accepted this revision.Nov 11 2021, 4:39 AM

LGTM

This revision is now accepted and ready to land.Nov 11 2021, 4:39 AM

Should we support VZEXT_MOVL for i16 with VMOVSHZrr just like what we support VZEXT_MOVL for i32?

diff --git a/llvm/lib/Target/X86/X86InstrAVX512.td b/llvm/lib/Target/X86/X86InstrAVX512.td
index 8aee96e1c504..4dca5490b26f 100644
--- a/llvm/lib/Target/X86/X86InstrAVX512.td
+++ b/llvm/lib/Target/X86/X86InstrAVX512.td
@@ -4659,6 +4659,8 @@ let Predicates = [HasAVX512] in {
 let Predicates = [HasFP16] in {
   def : Pat<(v8f16 (X86vzmovl (v8f16 VR128X:$src))),
             (VMOVSHZrr (v8f16 (AVX512_128_SET0)), VR128X:$src)>;
+  def : Pat<(v8i16 (X86vzmovl (v8i16 VR128X:$src))),
+            (VMOVSHZrr (v8i16 (AVX512_128_SET0)), VR128X:$src)>;

   // FIXME we need better canonicalization in dag combine
   def : Pat<(v16f16 (X86vzmovl (v16f16 VR256X:$src))),
pengfei updated this revision to Diff 386492.Nov 11 2021, 5:54 AM

Enable another use case.

Should we support VZEXT_MOVL for i16 with VMOVSHZrr just like what we support VZEXT_MOVL for i32?

diff --git a/llvm/lib/Target/X86/X86InstrAVX512.td b/llvm/lib/Target/X86/X86InstrAVX512.td
index 8aee96e1c504..4dca5490b26f 100644
--- a/llvm/lib/Target/X86/X86InstrAVX512.td
+++ b/llvm/lib/Target/X86/X86InstrAVX512.td
@@ -4659,6 +4659,8 @@ let Predicates = [HasAVX512] in {
 let Predicates = [HasFP16] in {
   def : Pat<(v8f16 (X86vzmovl (v8f16 VR128X:$src))),
             (VMOVSHZrr (v8f16 (AVX512_128_SET0)), VR128X:$src)>;
+  def : Pat<(v8i16 (X86vzmovl (v8i16 VR128X:$src))),
+            (VMOVSHZrr (v8i16 (AVX512_128_SET0)), VR128X:$src)>;

   // FIXME we need better canonicalization in dag combine
   def : Pat<(v16f16 (X86vzmovl (v16f16 VR256X:$src))),

I think it's OK for now since we only have these 2 cases for i16 that may create a VZEXT_MOVL node. If we adding pattern, we also need to duplicate for v16i16 and v32i16.

LuoYuanke accepted this revision.Nov 11 2021, 6:06 AM

LGTM, thanks.

This revision was automatically updated to reflect the committed changes.