From 9bbeaa7c56f15226e3c9882a6d28e028ebeacf25 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Thu, 26 Apr 2018 15:26:29 +0000 Subject: [PATCH] [NVPTX] Make the legalizer expand shufflevector of <2 x half> There's no direct instruction for this, but it's trivially implemented with two movs. Without this the code generator just dies when encountering a shufflevector. Differential Revision: https://reviews.llvm.org/D46116 llvm-svn: 330948 --- lib/Target/NVPTX/NVPTXISelLowering.cpp | 1 + test/CodeGen/NVPTX/f16x2-instructions.ll | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/lib/Target/NVPTX/NVPTXISelLowering.cpp b/lib/Target/NVPTX/NVPTXISelLowering.cpp index 5405e9dd001..527f0997e64 100644 --- a/lib/Target/NVPTX/NVPTXISelLowering.cpp +++ b/lib/Target/NVPTX/NVPTXISelLowering.cpp @@ -375,6 +375,7 @@ NVPTXTargetLowering::NVPTXTargetLowering(const NVPTXTargetMachine &TM, setOperationAction(ISD::FP_TO_SINT, MVT::f16, Legal); setOperationAction(ISD::BUILD_VECTOR, MVT::v2f16, Custom); setOperationAction(ISD::EXTRACT_VECTOR_ELT, MVT::v2f16, Custom); + setOperationAction(ISD::VECTOR_SHUFFLE, MVT::v2f16, Expand); setFP16OperationAction(ISD::SETCC, MVT::f16, Legal, Promote); setFP16OperationAction(ISD::SETCC, MVT::v2f16, Legal, Expand); diff --git a/test/CodeGen/NVPTX/f16x2-instructions.ll b/test/CodeGen/NVPTX/f16x2-instructions.ll index 5dc796ada37..3d58cfa3595 100644 --- a/test/CodeGen/NVPTX/f16x2-instructions.ll +++ b/test/CodeGen/NVPTX/f16x2-instructions.ll @@ -1423,5 +1423,13 @@ define <2 x half> @test_fmuladd(<2 x half> %a, <2 x half> %b, <2 x half> %c) #0 ret <2 x half> %r } +; CHECK-LABEL: test_shufflevector( +; CHECK: mov.b32 {%h1, %h2}, %hh1; +; CHECK: mov.b32 %hh2, {%h2, %h1}; +define <2 x half> @test_shufflevector(<2 x half> %a) #0 { + %s = shufflevector <2 x half> %a, <2 x half> undef, <2 x i32> + ret <2 x half> %s +} + attributes #0 = { nounwind } attributes #1 = { "unsafe-fp-math" = "true" }