[llvm] [X86] Prefer VPMOVMSKB for nonnegative byte comparison masks (PR #216884)
Oscar Priego via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 18 11:13:04 PDT 2026
================
@@ -46518,14 +46518,24 @@ static SDValue combineBitcastvxi1(SelectionDAG &DAG, EVT VT, SDValue Src,
Src.getOperand(0).getValueType() == MVT::v32i8 ||
Src.getOperand(0).getValueType() == MVT::v64i8);
- // Prefer movmsk for AVX512 for (bitcast (setlt X, 0)) which can be handled
+ // Prefer movmsk for AVX512 for (bitcast (setlt X, 0)), which can be handled
// directly with vpmovmskb/vmovmskps/vmovmskpd.
- if (Src.getOpcode() == ISD::SETCC && Src.hasOneUse() &&
- cast<CondCodeSDNode>(Src.getOperand(2))->get() == ISD::SETLT &&
- ISD::isBuildVectorAllZeros(Src.getOperand(1).getNode())) {
+ if (Src.getOpcode() == ISD::SETCC && Src.hasOneUse()) {
+ ISD::CondCode CC = cast<CondCodeSDNode>(Src.getOperand(2))->get();
EVT CmpVT = Src.getOperand(0).getValueType();
EVT EltVT = CmpVT.getVectorElementType();
- if (CmpVT.getSizeInBits() <= 256 &&
+ SDNode *RHS = Src.getOperand(1).getNode();
+
+ bool IsZero = ISD::isBuildVectorAllZeros(RHS);
+ bool IsNegativeTest = CC == ISD::SETLT && IsZero;
+
+ // For signed i8, x >= 0 and x > -1 both test that the sign bit is clear.
----------------
Opriego wrote:
Agreed. I'm looking at the i32/i64 cases as part of the rework and will update the PR once I've validated the broader approach.
https://github.com/llvm/llvm-project/pull/216884
More information about the llvm-commits
mailing list