[llvm] [X86] Generate `kmov` for masking integers (PR #120593)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 21 07:00:13 PST 2025
================
@@ -55293,6 +55293,95 @@ static SDValue truncateAVX512SetCCNoBWI(EVT VT, EVT OpVT, SDValue LHS,
return SDValue();
}
+static SDValue combineAVX512SetCCToKMOV(EVT VT, SDValue Op0, ISD::CondCode CC,
+ const SDLoc &DL, SelectionDAG &DAG,
+ const X86Subtarget &Subtarget) {
+ if (CC != ISD::SETNE && CC != ISD::SETEQ)
+ return SDValue();
+
+ if (!Subtarget.hasAVX512())
+ return SDValue();
+
+ if (Op0.getOpcode() != ISD::AND)
+ return SDValue();
+
+ SDValue Broadcast = Op0.getOperand(0);
+ if (Broadcast.getOpcode() != X86ISD::VBROADCAST &&
+ Broadcast.getOpcode() != X86ISD::VBROADCAST_LOAD)
+ return SDValue();
+
+ SDValue Load = Op0.getOperand(1);
+ if (Load.getOpcode() != ISD::LOAD)
----------------
RKSimon wrote:
You should be able to use getTargetConstantBitsFromNode to extract the element bits/undefs for the load:
```cpp
APInt UndefElts;
SmallVector<APInt> EltBits;
if (!getTargetConstantBitsFromNode(Op0.getOperand(1), VT.getScalarSizeInBits(), UndefElts, EltBits))
return SDValue();
```
https://github.com/llvm/llvm-project/pull/120593
More information about the llvm-commits
mailing list