[llvm] [RISCV] Select Zvkb VANDN for shorter constant loading sequences (PR #123345)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 21 12:03:44 PST 2025
================
@@ -3224,8 +3224,25 @@ bool RISCVDAGToDAGISel::selectInvLogicImm(SDValue N, SDValue &Val) {
// Abandon this transform if the constant is needed elsewhere.
for (const SDNode *U : N->users()) {
- if (!ISD::isBitwiseLogicOp(U->getOpcode()))
+ switch (U->getOpcode()) {
+ case ISD::AND:
+ case ISD::OR:
+ case ISD::XOR:
+ if (!(Subtarget->hasStdExtZbb() || Subtarget->hasStdExtZbkb()))
+ return false;
+ break;
+ case RISCVISD::VMV_V_X_VL:
+ if (!Subtarget->hasStdExtZvkb())
+ return false;
+ if (!all_of(U->users(), [](const SDNode *V) {
+ return V->getOpcode() == ISD::AND ||
+ V->getOpcode() == RISCVISD::AND_VL;
----------------
topperc wrote:
ISD::AND doesn't have a passthru. For RISCV::AND_VL you would need to loop through `U->uses()` instead of `U->users()`. That will give you an `SDUse &`. From there you can call `SDUse::getUser()` to get `V` and `SDUse::getOperandNo` to get the operand number of the use. The passthru will be operand 2.
https://github.com/llvm/llvm-project/pull/123345
More information about the llvm-commits
mailing list