@@ -5190,6 +5190,21 @@ static bool getTargetShuffleMaskIndices(SDValue MaskNode,
5190
5190
return true;
5191
5191
}
5192
5192
5193
+ static bool isConstantPowerOf2(SDValue V, unsigned EltSizeInBIts,
5194
+ bool AllowUndefs) {
5195
+ APInt UndefElts;
5196
+ SmallVector<APInt, 64> EltBits;
5197
+ if (!getTargetConstantBitsFromNode(V, EltSizeInBIts, UndefElts, EltBits,
5198
+ /*AllowWholeUndefs*/ AllowUndefs,
5199
+ /*AllowPartialUndefs*/ false))
5200
+ return false;
5201
+
5202
+ bool IsPow2OrUndef = true;
5203
+ for (unsigned I = 0, E = EltBits.size(); I != E; ++I)
5204
+ IsPow2OrUndef &= UndefElts[I] || EltBits[I].isPowerOf2();
5205
+ return IsPow2OrUndef;
5206
+ }
5207
+
5193
5208
// Match not(xor X, -1) -> X.
5194
5209
// Match not(pcmpgt(C, X)) -> pcmpgt(X, C - 1).
5195
5210
// Match not(extract_subvector(xor X, -1)) -> extract_subvector(X).
@@ -23600,17 +23615,11 @@ static SDValue LowerVSETCC(SDValue Op, const X86Subtarget &Subtarget,
23600
23615
// Revert part of the simplifySetCCWithAnd combine, to avoid an invert.
23601
23616
if (Cond == ISD::SETNE && ISD::isBuildVectorAllZeros(Op1.getNode())) {
23602
23617
SDValue BC0 = peekThroughBitcasts(Op0);
23603
- if (BC0.getOpcode() == ISD::AND) {
23604
- APInt UndefElts;
23605
- SmallVector<APInt, 64> EltBits;
23606
- if (getTargetConstantBitsFromNode(
23607
- BC0.getOperand(1), VT.getScalarSizeInBits(), UndefElts, EltBits,
23608
- /*AllowWholeUndefs*/ false, /*AllowPartialUndefs*/ false)) {
23609
- if (llvm::all_of(EltBits, [](APInt &V) { return V.isPowerOf2(); })) {
23610
- Cond = ISD::SETEQ;
23611
- Op1 = DAG.getBitcast(VT, BC0.getOperand(1));
23612
- }
23613
- }
23618
+ if (BC0.getOpcode() == ISD::AND &&
23619
+ isConstantPowerOf2(BC0.getOperand(1), VT.getScalarSizeInBits(),
23620
+ /*AllowUndefs=*/false)) {
23621
+ Cond = ISD::SETEQ;
23622
+ Op1 = DAG.getBitcast(VT, BC0.getOperand(1));
23614
23623
}
23615
23624
}
23616
23625
@@ -51224,20 +51233,11 @@ static SDValue combineOrXorWithSETCC(unsigned Opc, const SDLoc &DL, EVT VT,
51224
51233
if (Opc == ISD::XOR && N0.getOpcode() == X86ISD::PCMPEQ &&
51225
51234
N0.getOperand(0).getOpcode() == ISD::AND &&
51226
51235
ISD::isBuildVectorAllZeros(N0.getOperand(1).getNode()) &&
51227
- ISD::isBuildVectorAllOnes(N1.getNode())) {
51228
- APInt UndefElts;
51229
- SmallVector<APInt> EltBits;
51230
- if (getTargetConstantBitsFromNode(N0.getOperand(0).getOperand(1),
51231
- VT.getScalarSizeInBits(), UndefElts,
51232
- EltBits)) {
51233
- bool IsPow2OrUndef = true;
51234
- for (unsigned I = 0, E = EltBits.size(); I != E; ++I)
51235
- IsPow2OrUndef &= UndefElts[I] || EltBits[I].isPowerOf2();
51236
-
51237
- if (IsPow2OrUndef)
51238
- return DAG.getNode(X86ISD::PCMPEQ, DL, VT, N0.getOperand(0),
51239
- N0.getOperand(0).getOperand(1));
51240
- }
51236
+ ISD::isBuildVectorAllOnes(N1.getNode()) &&
51237
+ isConstantPowerOf2(N0.getOperand(0).getOperand(1),
51238
+ VT.getScalarSizeInBits(), /*AllowUndefs=*/true)) {
51239
+ return DAG.getNode(X86ISD::PCMPEQ, DL, VT, N0.getOperand(0),
51240
+ N0.getOperand(0).getOperand(1));
51241
51241
}
51242
51242
51243
51243
return SDValue();
0 commit comments