[llvm] [SelectionDAG] Scalarize binary ops of splats before legal types (PR #100749)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 9 21:39:24 PDT 2024
================
@@ -26993,11 +26993,20 @@ static SDValue scalarizeBinOpOfSplats(SDNode *N, SelectionDAG &DAG,
// TODO: use DAG.isSplatValue instead?
bool IsBothSplatVector = N0.getOpcode() == ISD::SPLAT_VECTOR &&
N1.getOpcode() == ISD::SPLAT_VECTOR;
+
+ // If binop is legal or custom on EltVT, scalarize should be profitable. The
+ // check is the same as isOperationLegalOrCustom without isTypeLegal. We
+ // can do this only before LegalTypes, because it may generate illegal `op
+ // EltVT` from legal `op VT (splat EltVT)`, where EltVT is not legal type but
+ // the result type of splat is legal.
+ auto EltAction = TLI.getOperationAction(Opcode, EltVT);
if (!Src0 || !Src1 || Index0 != Index1 ||
Src0.getValueType().getVectorElementType() != EltVT ||
Src1.getValueType().getVectorElementType() != EltVT ||
!(IsBothSplatVector || TLI.isExtractVecEltCheap(VT, Index0)) ||
- !TLI.isOperationLegalOrCustom(Opcode, EltVT))
+ (LegalTypes && !TLI.isTypeLegal(EltVT)) ||
+ !(EltAction == TargetLoweringBase::Legal ||
+ EltAction == TargetLoweringBase::Custom))
----------------
Fros1er wrote:
I misunderstood how LegalTypes stage works. I thought that stage will eventually make all illegal types legal so I didn't do the check. Thanks for your suggestion :)
https://github.com/llvm/llvm-project/pull/100749
More information about the llvm-commits
mailing list