[llvm] [X86] ReplaceNodeResults - truncate sub-128-bit vectors as shuffles directly (PR #83120)
Phoebe Wang via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 27 03:47:45 PST 2024
================
@@ -32341,20 +32341,20 @@ void X86TargetLowering::ReplaceNodeResults(SDNode *N,
}
}
- if (128 % InBits == 0) {
+ if ((128 % InBits) == 0 && WidenVT.is128BitVector()) {
// 128 bit and smaller inputs should avoid truncate all together and
- // just use a build_vector that will become a shuffle.
- // TODO: Widen and use a shuffle directly?
- SmallVector<SDValue, 16> Ops(WidenNumElts, DAG.getUNDEF(EltVT));
- // Use the original element count so we don't do more scalar opts than
- // necessary.
- for (unsigned i=0; i < MinElts; ++i) {
- SDValue Val = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, InEltVT, In,
- DAG.getIntPtrConstant(i, dl));
- Ops[i] = DAG.getNode(ISD::TRUNCATE, dl, EltVT, Val);
- }
- Results.push_back(DAG.getBuildVector(WidenVT, dl, Ops));
- return;
+ // use a shuffle.
+ if ((InEltVT.getSizeInBits() % EltVT.getSizeInBits()) == 0) {
----------------
phoebewang wrote:
Can `EltVT` be `i4`, `i2` etc.? Should we check `EltVT` legal?
https://github.com/llvm/llvm-project/pull/83120
More information about the llvm-commits
mailing list