diff options
author | Krzysztof Parzyszek <kparzysz@quicinc.com> | 2019-09-23 14:33:27 +0000 |
---|---|---|
committer | Krzysztof Parzyszek <kparzysz@quicinc.com> | 2019-09-23 14:33:27 +0000 |
commit | f97fdf5792c39fd2fe47e7c64e0e97adbf281b2b (patch) | |
tree | cdd519bf0dcbdd0ca05690fdf3bad9faa2c2d91b | |
parent | a0d84ffee853a336752539a453b4442bf996755a (diff) | |
download | bcm5719-llvm-f97fdf5792c39fd2fe47e7c64e0e97adbf281b2b.tar.gz bcm5719-llvm-f97fdf5792c39fd2fe47e7c64e0e97adbf281b2b.zip |
[Hexagon] Bitcast v4i16 to v8i8, unify no-op casts between scalar and HVX
llvm-svn: 372616
-rw-r--r-- | llvm/lib/Target/Hexagon/HexagonPatterns.td | 30 | ||||
-rw-r--r-- | llvm/lib/Target/Hexagon/HexagonPatternsHVX.td | 23 | ||||
-rw-r--r-- | llvm/test/CodeGen/Hexagon/isel-bitcast-v8i8-v4i16.ll | 13 |
3 files changed, 39 insertions, 27 deletions
diff --git a/llvm/lib/Target/Hexagon/HexagonPatterns.td b/llvm/lib/Target/Hexagon/HexagonPatterns.td index c54be2f16f1..485e658e1c8 100644 --- a/llvm/lib/Target/Hexagon/HexagonPatterns.td +++ b/llvm/lib/Target/Hexagon/HexagonPatterns.td @@ -344,6 +344,13 @@ multiclass MinMax_pats<InstHexagon PickT, InstHexagon PickS, (PickS CmpPred:$Vs, CmpPred:$Vt)>; } +// Bitcasts between same-size vector types are no-ops, except for the +// actual type change. +multiclass NopCast_pat<ValueType Ty1, ValueType Ty2, RegisterClass RC> { + def: Pat<(Ty1 (bitconvert (Ty2 RC:$Val))), (Ty1 RC:$Val)>; + def: Pat<(Ty2 (bitconvert (Ty1 RC:$Val))), (Ty2 RC:$Val)>; +} + // Frags for commonly used SDNodes. def Add: pf2<add>; def And: pf2<and>; def Sra: pf2<sra>; @@ -427,17 +434,18 @@ def: Pat<(f32 (bitconvert I32:$v)), (F32:$v)>; def: Pat<(i64 (bitconvert F64:$v)), (I64:$v)>; def: Pat<(f64 (bitconvert I64:$v)), (F64:$v)>; -multiclass Cast_pat<ValueType Ta, ValueType Tb, RegisterClass RC> { - def: Pat<(Tb (bitconvert (Ta RC:$Rs))), (Tb RC:$Rs)>; - def: Pat<(Ta (bitconvert (Tb RC:$Rs))), (Ta RC:$Rs)>; -} - -// Bit convert vector types to integers. -defm: Cast_pat<v4i8, i32, IntRegs>; -defm: Cast_pat<v2i16, i32, IntRegs>; -defm: Cast_pat<v8i8, i64, DoubleRegs>; -defm: Cast_pat<v4i16, i64, DoubleRegs>; -defm: Cast_pat<v2i32, i64, DoubleRegs>; +// Bit convert 32- and 64-bit types. +// All of these are bitcastable to one another: i32, v2i16, v4i8. +defm: NopCast_pat<i32, v2i16, IntRegs>; +defm: NopCast_pat<i32, v4i8, IntRegs>; +defm: NopCast_pat<v2i16, v4i8, IntRegs>; +// All of these are bitcastable to one another: i64, v2i32, v4i16, v8i8. +defm: NopCast_pat<i64, v2i32, DoubleRegs>; +defm: NopCast_pat<i64, v4i16, DoubleRegs>; +defm: NopCast_pat<i64, v8i8, DoubleRegs>; +defm: NopCast_pat<v2i32, v4i16, DoubleRegs>; +defm: NopCast_pat<v2i32, v8i8, DoubleRegs>; +defm: NopCast_pat<v4i16, v8i8, DoubleRegs>; // --(3) Extend/truncate ------------------------------------------------- diff --git a/llvm/lib/Target/Hexagon/HexagonPatternsHVX.td b/llvm/lib/Target/Hexagon/HexagonPatternsHVX.td index 32e2260de07..078a7135c55 100644 --- a/llvm/lib/Target/Hexagon/HexagonPatternsHVX.td +++ b/llvm/lib/Target/Hexagon/HexagonPatternsHVX.td @@ -160,23 +160,14 @@ let Predicates = [UseHVX] in { // Bitcasts between same-size vector types are no-ops, except for the // actual type change. -class Bitcast<ValueType ResTy, ValueType InpTy, RegisterClass RC> - : Pat<(ResTy (bitconvert (InpTy RC:$Val))), (ResTy RC:$Val)>; - let Predicates = [UseHVX] in { - def: Bitcast<VecI8, VecI16, HvxVR>; - def: Bitcast<VecI8, VecI32, HvxVR>; - def: Bitcast<VecI16, VecI8, HvxVR>; - def: Bitcast<VecI16, VecI32, HvxVR>; - def: Bitcast<VecI32, VecI8, HvxVR>; - def: Bitcast<VecI32, VecI16, HvxVR>; - - def: Bitcast<VecPI8, VecPI16, HvxWR>; - def: Bitcast<VecPI8, VecPI32, HvxWR>; - def: Bitcast<VecPI16, VecPI8, HvxWR>; - def: Bitcast<VecPI16, VecPI32, HvxWR>; - def: Bitcast<VecPI32, VecPI8, HvxWR>; - def: Bitcast<VecPI32, VecPI16, HvxWR>; + defm: NopCast_pat<VecI8, VecI16, HvxVR>; + defm: NopCast_pat<VecI8, VecI32, HvxVR>; + defm: NopCast_pat<VecI16, VecI32, HvxVR>; + + defm: NopCast_pat<VecPI8, VecPI16, HvxWR>; + defm: NopCast_pat<VecPI8, VecPI32, HvxWR>; + defm: NopCast_pat<VecPI16, VecPI32, HvxWR>; } let Predicates = [UseHVX] in { diff --git a/llvm/test/CodeGen/Hexagon/isel-bitcast-v8i8-v4i16.ll b/llvm/test/CodeGen/Hexagon/isel-bitcast-v8i8-v4i16.ll new file mode 100644 index 00000000000..f45b1a77c6d --- /dev/null +++ b/llvm/test/CodeGen/Hexagon/isel-bitcast-v8i8-v4i16.ll @@ -0,0 +1,13 @@ +; RUN: llc -march=hexagon < %s | FileCheck %s + +; Check that this doesn't fail to select instructions. +; CHECK: vsplath + +define <8 x i8> @fred(i16 %a0) #0 { + %t0 = insertelement <4 x i16> undef, i16 %a0, i32 0 + %t1 = shufflevector <4 x i16> %t0, <4 x i16> undef, <4 x i32> zeroinitializer + %t2 = bitcast <4 x i16> %t1 to <8 x i8> + ret <8 x i8> %t2 +} + +attributes #0 = { readnone nounwind "target-cpu"="hexagonv62" } |