[llvm] [MIPS]Remove unnecessary SLL instructions on MIPS64el (PR #109386)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 29 19:49:35 PDT 2025
================
@@ -1221,6 +1222,37 @@ static SDValue performSHLCombine(SDNode *N, SelectionDAG &DAG,
DAG.getConstant(SMSize, DL, MVT::i32));
}
+static SDValue performSignExtendCombine(SDNode *N, SelectionDAG &DAG,
+ TargetLowering::DAGCombinerInfo &DCI,
+ const MipsSubtarget &Subtarget) {
+ if (DCI.Level != AfterLegalizeDAG || !Subtarget.isGP64bit()) {
+ return SDValue();
+ }
+
+ SDValue N0 = N->getOperand(0);
+ EVT VT = N->getValueType(0);
+
+ // Pattern match XOR.
+ // $dst = sign_extend (xor (trunc $src, i32), imm)
+ // => $dst = xor (signext_inreg $src, i32), imm
+ if (N0.getOpcode() == ISD::XOR &&
+ N0.getOperand(0).getOpcode() == ISD::TRUNCATE &&
+ N0.getOperand(1).getOpcode() == ISD::Constant) {
+ SDValue TruncateSource = N0.getOperand(0).getOperand(0);
+ auto *ConstantOperand = dyn_cast<ConstantSDNode>(N0->getOperand(1));
+ if (VT == MVT::i64 && VT == TruncateSource.getValueType()) {
----------------
yingopq wrote:
Do we have to put a limit here?
If the input parameter is i16, can it also be adapted to this optimization?
https://github.com/llvm/llvm-project/pull/109386
More information about the llvm-commits
mailing list