Skip to content

Commit 2f6d881

Browse files
svs-quicgithub-actions[bot]
authored andcommitted
Automerge: [RISCV] Use QC_E_ADDI to improve codegen for icmp {eq, ne} with a constant (#139558)
Use the QC_E_ADDI instruction when the constant is not a signed 12 bit value but is a signed 26 bit one. Don't use it if a single LUI instruction can be used instead.
2 parents 10ec9c2 + 595544b commit 2f6d881

File tree

2 files changed

+455
-0
lines changed

2 files changed

+455
-0
lines changed

llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2997,6 +2997,18 @@ bool RISCVDAGToDAGISel::selectSETCC(SDValue N, ISD::CondCode ExpectedCCVal,
29972997
0);
29982998
return true;
29992999
}
3000+
// Same as the addi case above but for larger immediates (signed 26-bit) use
3001+
// the QC_E_ADDI instruction from the Xqcilia extension, if available. Avoid
3002+
// anything which can be done with a single lui as it might be compressible.
3003+
if (Subtarget->hasVendorXqcilia() && isInt<26>(CVal) &&
3004+
(CVal & 0xFFF) != 0) {
3005+
Val = SDValue(
3006+
CurDAG->getMachineNode(
3007+
RISCV::QC_E_ADDI, DL, N->getValueType(0), LHS,
3008+
CurDAG->getSignedTargetConstant(-CVal, DL, N->getValueType(0))),
3009+
0);
3010+
return true;
3011+
}
30003012
}
30013013

30023014
// If nothing else we can XOR the LHS and RHS to produce zero if they are

0 commit comments

Comments
 (0)