@@ -7543,6 +7543,20 @@ static bool isFoldableUseOfShuffle(SDNode *N) {
7543
7543
return false;
7544
7544
}
7545
7545
7546
+ // If the node has a single use by a VSELECT then AVX512 targets may be able to
7547
+ // fold as a predicated instruction.
7548
+ static bool isMaskableNode(SDValue V, const X86Subtarget &Subtarget) {
7549
+ unsigned SizeInBits = V.getValueSizeInBits();
7550
+ if ((SizeInBits == 512 && Subtarget.hasAVX512()) ||
7551
+ (SizeInBits >= 128 && Subtarget.hasVLX())) {
7552
+ if (V.hasOneUse() && V->user_begin()->getOpcode() == ISD::VSELECT &&
7553
+ V->user_begin()->getOperand(0).getScalarValueSizeInBits() == 1) {
7554
+ return true;
7555
+ }
7556
+ }
7557
+ return false;
7558
+ }
7559
+
7546
7560
/// Attempt to use the vbroadcast instruction to generate a splat value
7547
7561
/// from a splat BUILD_VECTOR which uses:
7548
7562
/// a. A single scalar load, or a constant.
@@ -41259,13 +41273,7 @@ static SDValue combineX86ShufflesRecursively(
41259
41273
41260
41274
// If we are a AVX512/EVEX target the mask element size should match the root
41261
41275
// element size to allow writemasks to be reused.
41262
- bool IsMaskedShuffle = false;
41263
- if (RootSizeInBits == 512 || (Subtarget.hasVLX() && RootSizeInBits >= 128)) {
41264
- if (Root.hasOneUse() && Root->user_begin()->getOpcode() == ISD::VSELECT &&
41265
- Root->user_begin()->getOperand(0).getScalarValueSizeInBits() == 1) {
41266
- IsMaskedShuffle = true;
41267
- }
41268
- }
41276
+ bool IsMaskedShuffle = isMaskableNode(Root, Subtarget);
41269
41277
41270
41278
// We can only combine unary and binary shuffle mask cases.
41271
41279
if (Ops.size() <= 2) {
0 commit comments