[llvm] [X86] combineShiftRightLogical - fold srl(vecreduce_umax(x),bw-1) as MOVMSK signbit reduction (PR #210281)
Phoebe Wang via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 18 07:35:38 PDT 2026
================
@@ -50917,6 +50910,33 @@ static SDValue combineShiftRightLogical(SDNode *N, SelectionDAG &DAG,
}
}
+ // VectorCombine may have folded:
+ // icmp_eq(vecreduce_or(splatsign(x)),0) --> icmp_sgt(vecreduce_umax(x),-1)
+ // which DAG folds to: srl(vecreduce_umax(x),bw-1).
+ // This attempts to reconstruct the signbit reduction.
+ if (sd_match(N1, m_SpecificInt(EltSizeInBits - 1))) {
+ SDValue X = N0;
+ ISD::CondCode CC = ISD::SETNE;
+ if (sd_match(N0, m_Not(m_Value(X))))
+ CC = ISD::SETEQ;
+ if (X.getOpcode() == ISD::VECREDUCE_UMAX) {
+ SDValue V = X.getOperand(0);
+ EVT VecVT = V.getValueType();
+ if (DAG.getTargetLoweringInfo().isTypeLegal(VecVT) &&
+ (VecVT.is128BitVector() || VecVT.is256BitVector())) {
----------------
phoebewang wrote:
Why exclude 512-bit?
https://github.com/llvm/llvm-project/pull/210281
More information about the llvm-commits
mailing list