================
@@ -13086,6 +13086,13 @@ SDValue
RISCVTargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op,
return DAG.getNode(getRVPShiftOpcode(IntNo), DL, Op.getValueType(),
Op.getOperand(1), ShAmt);
}
+ case Intrinsic::riscv_psati:
+ case Intrinsic::riscv_pusati: {
+ unsigned Opc =
+ IntNo == Intrinsic::riscv_psati ? RISCVISD::PSATI : RISCVISD::PUSATI;
+ SDValue Width = DAG.getAnyExtOrTrunc(Op.getOperand(2), DL, XLenVT);
----------------
sihuan wrote:
Done. It builds the TargetConstant directly now, and the patterns match it with
timm based leaves instead of the ImmLeaf based uimm4_plus1/uimm5 they used
before.
On your question: it does get folded, but the fold drops the TargetConstant.
FoldConstantArithmetic() passes SDNode::isTargetOpcode() as the isTarget
argument of getConstant(), and that predicate tests
NodeType >= ISD::BUILTIN_OP_END. A ConstantSDNode is only ever ISD::Constant or
ISD::TargetConstant, both below BUILTIN_OP_END, so it is always false and the
result is a plain Constant. As far as I can tell that is the only reason the
previous version matched at all, since ImmLeaf matches ISD::Constant only, so
you were right to be suspicious.
Nothing in this PR depends on that any more, so this is only a side question,
and I may well be missing context here: is that the intended behaviour? The
options I could think of are
- spelling the argument `/*isTarget=*/false`, so the code says what it does;
- propagating the kind for real (C->getOpcode() == ISD::TargetConstant);
- not folding when the operand is a TargetConstant.
For what it is worth, propagating keeps CodeGen/X86 and CodeGen/RISCV passing
here, and instrumenting those folds to abort on a TargetConstant operand never
fires across them, so nothing in tree seems to feed an immediate field into
that code today. The same expression also appears in the ISD::PARITY fold added
recently in 03a6445dd283.
Happy to send a patch for whichever direction you prefer, or to leave it alone.
https://github.com/llvm/llvm-project/pull/224432
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits