From: Krzysztof Parzyszek Date: Fri, 15 Dec 2017 21:23:12 +0000 (+0000) Subject: [Hexagon] Handle concat_vectors of all allowed HVX types X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a211d55b2f784ef4bb25bfe5b1dcbdbbaed4d71e;p=llvm [Hexagon] Handle concat_vectors of all allowed HVX types git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320865 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/Hexagon/HexagonPatterns.td b/lib/Target/Hexagon/HexagonPatterns.td index 05c8f871bdd..f8507036bbf 100644 --- a/lib/Target/Hexagon/HexagonPatterns.td +++ b/lib/Target/Hexagon/HexagonPatterns.td @@ -973,14 +973,6 @@ let AddedComplexity = 75 in { (A2_combineii imm:$s8, imm:$S8)>; } -let Predicates = [UseHVX] in { - def: OpR_RR_pat, VecPI32, HVI32>; - def: OpR_RR_pat, VecI8, HVI8>; - def: OpR_RR_pat, VecI8, HVI8>; - def: OpR_RR_pat, VecI16, HVI16>; - def: OpR_RR_pat, VecI16, HVI16>; -} - def: Pat<(bswap I32:$Rs), (A2_swiz I32:$Rs)>; def: Pat<(bswap I64:$Rss), (Combinew (A2_swiz (LoReg $Rss)), (A2_swiz (HiReg $Rss)))>; @@ -2906,6 +2898,7 @@ def HexagonREADCYCLE: SDNode<"HexagonISD::READCYCLE", SDTInt64Leaf, def: Pat<(HexagonREADCYCLE), (A4_tfrcpp UPCYCLE)>; + def SDTHexagonVEXTRACTW: SDTypeProfile<1, 2, [SDTCisVT<0, i32>, SDTCisVec<1>, SDTCisVT<2, i32>]>; def HexagonVEXTRACTW : SDNode<"HexagonISD::VEXTRACTW", SDTHexagonVEXTRACTW>; @@ -2914,9 +2907,23 @@ def SDTHexagonVINSERTW0: SDTypeProfile<1, 2, [SDTCisVec<0>, SDTCisSameAs<0, 1>, SDTCisVT<2, i32>]>; def HexagonVINSERTW0 : SDNode<"HexagonISD::VINSERTW0", SDTHexagonVINSERTW0>; +def Combinev: OutPatFrag<(ops node:$Rs, node:$Rt), + (REG_SEQUENCE HvxWR, $Rs, vsub_hi, $Rt, vsub_lo)>; + +let Predicates = [UseHVX] in { + def: OpR_RR_pat, VecI8, HVI8>; + def: OpR_RR_pat, VecI8, HVI8>; + def: OpR_RR_pat, VecI16, HVI16>; + def: OpR_RR_pat, VecI16, HVI16>; +} + let Predicates = [UseHVX] in { - def: Pat<(concat_vectors HVI8:$Vs, HVI8:$Vt), - (V6_vcombine HvxVR:$Vt, HvxVR:$Vs)>; + def: Pat<(VecPI8 (concat_vectors HVI8:$Vs, HVI8:$Vt)), + (Combinev HvxVR:$Vt, HvxVR:$Vs)>; + def: Pat<(VecPI16 (concat_vectors HVI16:$Vs, HVI16:$Vt)), + (Combinev HvxVR:$Vt, HvxVR:$Vs)>; + def: Pat<(VecPI32 (concat_vectors HVI32:$Vs, HVI32:$Vt)), + (Combinev HvxVR:$Vt, HvxVR:$Vs)>; def: Pat<(HexagonVEXTRACTW HVI8:$Vu, I32:$Rs), (V6_extractw HvxVR:$Vu, I32:$Rs)>; diff --git a/test/CodeGen/Hexagon/autohvx/concat-vectors-128b.ll b/test/CodeGen/Hexagon/autohvx/concat-vectors-128b.ll new file mode 100644 index 00000000000..660c7365d2e --- /dev/null +++ b/test/CodeGen/Hexagon/autohvx/concat-vectors-128b.ll @@ -0,0 +1,27 @@ +; RUN: llc -march=hexagon < %s | FileCheck %s + +; CHECK-LABEL: concat_8: +; CHECK: v[[H00:[0-9]+]]:[[L00:[0-9]+]] = vcombine(v0,v1) +; CHECK: v1:0 = vcombine(v[[H00]],v[[L00]]) +define <256 x i8> @concat_8(<128 x i8> %v0, <128 x i8> %v1) #0 { + %p = shufflevector <128 x i8> %v0, <128 x i8> %v1, <256 x i32> + ret <256 x i8> %p +} + +; CHECK-LABEL: concat_16: +; CHECK: v[[H00:[0-9]+]]:[[L00:[0-9]+]] = vcombine(v0,v1) +; CHECK: v1:0 = vcombine(v[[H00]],v[[L00]]) +define <128 x i16> @concat_16(<64 x i16> %v0, <64 x i16> %v1) #0 { + %p = shufflevector <64 x i16> %v0, <64 x i16> %v1, <128 x i32> + ret <128 x i16> %p +} + +; CHECK-LABEL: concat_32: +; CHECK: v[[H10:[0-9]+]]:[[L10:[0-9]+]] = vcombine(v0,v1) +; CHECK: v1:0 = vcombine(v[[H10]],v[[L10]]) +define <64 x i32> @concat_32(<32 x i32> %v0, <32 x i32> %v1) #0 { + %p = shufflevector <32 x i32> %v0, <32 x i32> %v1, <64 x i32> + ret <64 x i32> %p +} + +attributes #0 = { nounwind readnone "target-cpu"="hexagonv60" "target-features"="+hvx,+hvx-length128b" } diff --git a/test/CodeGen/Hexagon/autohvx/concat-vectors-64b.ll b/test/CodeGen/Hexagon/autohvx/concat-vectors-64b.ll new file mode 100644 index 00000000000..47011fb6308 --- /dev/null +++ b/test/CodeGen/Hexagon/autohvx/concat-vectors-64b.ll @@ -0,0 +1,27 @@ +; RUN: llc -march=hexagon < %s | FileCheck %s + +; CHECK-LABEL: concat_8: +; CHECK: v[[H00:[0-9]+]]:[[L00:[0-9]+]] = vcombine(v0,v1) +; CHECK: v1:0 = vcombine(v[[H00]],v[[L00]]) +define <128 x i8> @concat_8(<64 x i8> %v0, <64 x i8> %v1) #0 { + %p = shufflevector <64 x i8> %v0, <64 x i8> %v1, <128 x i32> + ret <128 x i8> %p +} + +; CHECK-LABEL: concat_16: +; CHECK: v[[H10:[0-9]+]]:[[L10:[0-9]+]] = vcombine(v0,v1) +; CHECK: v1:0 = vcombine(v[[H10]],v[[L10]]) +define <64 x i16> @concat_16(<32 x i16> %v0, <32 x i16> %v1) #0 { + %p = shufflevector <32 x i16> %v0, <32 x i16> %v1, <64 x i32> + ret <64 x i16> %p +} + +; CHECK-LABEL: concat_32: +; CHECK: v[[H20:[0-9]+]]:[[L20:[0-9]+]] = vcombine(v0,v1) +; CHECK: v1:0 = vcombine(v[[H20]],v[[L20]]) +define <32 x i32> @concat_32(<16 x i32> %v0, <16 x i32> %v1) #0 { + %p = shufflevector <16 x i32> %v0, <16 x i32> %v1, <32 x i32> + ret <32 x i32> %p +} + +attributes #0 = { nounwind readnone "target-cpu"="hexagonv60" "target-features"="+hvx,+hvx-length64b" } diff --git a/test/CodeGen/Hexagon/autohvx/isel-concat-vectors.ll b/test/CodeGen/Hexagon/autohvx/isel-concat-vectors.ll new file mode 100644 index 00000000000..5e37ef088cf --- /dev/null +++ b/test/CodeGen/Hexagon/autohvx/isel-concat-vectors.ll @@ -0,0 +1,28 @@ +; RUN: llc -march=hexagon < %s | FileCheck %s + +; Check for a non-crashing output. +; CHECK: vsplat + +target datalayout = "e-m:e-p:32:32:32-a:0-n16:32-i64:64:64-i32:32:32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-v32:32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048:2048:2048" +target triple = "hexagon-unknown--elf" + +declare <16 x i32> @llvm.hexagon.V6.lo(<32 x i32>) #0 +declare <32 x i32> @llvm.hexagon.V6.vshuffvdd(<16 x i32>, <16 x i32>, i32) #0 +declare <16 x i32> @llvm.hexagon.V6.lvsplatw(i32) #0 + +define void @crash() #1 { +b0: + %v1 = tail call <16 x i32> @llvm.hexagon.V6.lvsplatw(i32 0) #0 + %v2 = bitcast <16 x i32> %v1 to <32 x i16> + %v3 = shufflevector <32 x i16> %v2, <32 x i16> undef, <128 x i32> + %v4 = shufflevector <128 x i16> %v3, <128 x i16> undef, <64 x i32> + %v5 = bitcast <64 x i16> %v4 to <32 x i32> + %v6 = tail call <16 x i32> @llvm.hexagon.V6.lo(<32 x i32> %v5) #0 + %v7 = tail call <32 x i32> @llvm.hexagon.V6.vshuffvdd(<16 x i32> undef, <16 x i32> %v6, i32 -2) #0 + %v8 = tail call <16 x i32> @llvm.hexagon.V6.lo(<32 x i32> %v7) + store <16 x i32> %v8, <16 x i32>* undef, align 2 + unreachable +} + +attributes #0 = { nounwind readnone } +attributes #1 = { nounwind "target-cpu"="hexagonv60" "target-features"="+hvx,+hvx-length64b" }