[llvm] [Hexagon] Fix up vector predicate before compressing it for "bitcast" (PR #199283)
Brian Cain via llvm-commits
llvm-commits at lists.llvm.org
Sat May 23 09:47:00 PDT 2026
================
@@ -2111,6 +2111,32 @@ HexagonTargetLowering::LowerHvxBitcast(SDValue Op, SelectionDAG &DAG) const {
if (isHvxBoolTy(ValTy) && ResTy.isScalarInteger()) {
unsigned HwLen = Subtarget.getVectorLength();
MVT WordTy = MVT::getVectorVT(MVT::i32, HwLen/4);
+
+ // Example : In 128B mode
+ // Val with v64i1, each i1 is represented by 2 bits of predicate register.
+ // Val with v32i1, each i1 is represented by 4 bits of predicate register.
+ // The Val (predicate register) needs to be fixed before we compress it.
+ // Eg: For a v64i1, q0: 0x0000ffff represents that the last 8 bits are
+ // sent.
+
+ // For v64i1, lower half of vector predicate register is used.
+ // Logic for conversion:
+ // Q->V
+ // deal
+ // V->Q
+
+ unsigned PredLen = ValTy.getVectorNumElements();
+ if ((HwLen == 128 && PredLen < 128) || (HwLen == 64 && PredLen < 64)) {
+ SDValue Deal;
+ MVT ByteTy = MVT::getVectorVT(MVT::i8, HwLen);
+ Val = DAG.getNode(HexagonISD::Q2V, dl, ByteTy, Val);
+ bool ReDeal = (HwLen / PredLen == 4);
+ if (ReDeal)
+ Deal = getInstr(Hexagon::V6_vdealh, dl, ByteTy, Val, DAG);
----------------
androm3da wrote:
Does the test sufficiently cover both `ReDeal` cases?
https://github.com/llvm/llvm-project/pull/199283
More information about the llvm-commits
mailing list