Skip to content

Commit

Permalink
[llvm] Skip getAPIntValue (NFC)
Browse files Browse the repository at this point in the history
ConstantSDNode provides some convenience functions like isZero,
getZExtValue, and isMinSignedValue that are named identically to those
provided by APInt, so we can "skip" getAPIntValue.
  • Loading branch information
kazutakahirata committed Mar 23, 2023
1 parent 4524db7 commit 7bb6d1b
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4105,7 +4105,7 @@ SDValue DAGCombiner::visitSUBO(SDNode *N) {
ConstantSDNode *N1C = getAsNonOpaqueConstant(N1);

// fold (subox, c) -> (addo x, -c)
if (IsSigned && N1C && !N1C->getAPIntValue().isMinSignedValue()) {
if (IsSigned && N1C && !N1C->isMinSignedValue()) {
return DAG.getNode(ISD::SADDO, DL, N->getVTList(), N0,
DAG.getConstant(-N1C->getAPIntValue(), DL, VT));
}
Expand Down Expand Up @@ -4585,7 +4585,7 @@ SDValue DAGCombiner::visitSDIV(SDNode *N) {
return DAG.getNegative(N0, DL, VT);

// fold (sdiv X, MIN_SIGNED) -> select(X == MIN_SIGNED, 1, 0)
if (N1C && N1C->getAPIntValue().isMinSignedValue())
if (N1C && N1C->isMinSignedValue())
return DAG.getSelect(DL, VT, DAG.getSetCC(DL, CCVT, N0, N1, ISD::SETEQ),
DAG.getConstant(1, DL, VT),
DAG.getConstant(0, DL, VT));
Expand Down
7 changes: 3 additions & 4 deletions llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3908,8 +3908,7 @@ SDValue TargetLowering::optimizeSetCCOfSignedTruncationCheck(
SDValue TargetLowering::optimizeSetCCByHoistingAndByConstFromLogicalShift(
EVT SCCVT, SDValue N0, SDValue N1C, ISD::CondCode Cond,
DAGCombinerInfo &DCI, const SDLoc &DL) const {
assert(isConstOrConstSplat(N1C) &&
isConstOrConstSplat(N1C)->getAPIntValue().isZero() &&
assert(isConstOrConstSplat(N1C) && isConstOrConstSplat(N1C)->isZero() &&
"Should be a comparison with 0.");
assert((Cond == ISD::SETEQ || Cond == ISD::SETNE) &&
"Valid only for [in]equality comparisons.");
Expand Down Expand Up @@ -4738,8 +4737,8 @@ SDValue TargetLowering::SimplifySetCC(EVT VT, SDValue N0, SDValue N1,
// For example, when high 32-bits of i64 X are known clear:
// all bits clear: (X | (Y<<32)) == 0 --> (X | Y) == 0
// all bits set: (X | (Y<<32)) == -1 --> (X & Y) == -1
bool CmpZero = N1C->getAPIntValue().isZero();
bool CmpNegOne = N1C->getAPIntValue().isAllOnes();
bool CmpZero = N1C->isZero();
bool CmpNegOne = N1C->isAllOnes();
if ((CmpZero || CmpNegOne) && N0.hasOneUse()) {
// Match or(lo,shl(hi,bw/2)) pattern.
auto IsConcat = [&](SDValue V, SDValue &Lo, SDValue &Hi) {
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2770,7 +2770,7 @@ bool AMDGPUDAGToDAGISel::SelectDotIUVOP3PMods(SDValue In, SDValue &Src) const {
assert(C->getAPIntValue().getBitWidth() == 1 && "expected i1 value");

unsigned Mods = SISrcMods::OP_SEL_1;
unsigned SrcSign = C->getAPIntValue().getZExtValue();
unsigned SrcSign = C->getZExtValue();
if (SrcSign == 1)
Mods ^= SISrcMods::NEG;

Expand All @@ -2784,7 +2784,7 @@ bool AMDGPUDAGToDAGISel::SelectWMMAOpSelVOP3PMods(SDValue In,
assert(C->getAPIntValue().getBitWidth() == 1 && "expected i1 value");

unsigned Mods = SISrcMods::OP_SEL_1;
unsigned SrcVal = C->getAPIntValue().getZExtValue();
unsigned SrcVal = C->getZExtValue();
if (SrcVal == 1)
Mods |= SISrcMods::OP_SEL_0;

Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/Target/AVR/AVRISelDAGToDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,7 @@ bool AVRDAGToDAGISel::SelectInlineAsmMemoryOperand(
}

if (ImmNode->getValueType(0) != MVT::i8) {
Disp = CurDAG->getTargetConstant(
ImmNode->getAPIntValue().getZExtValue(), dl, MVT::i8);
Disp = CurDAG->getTargetConstant(ImmNode->getZExtValue(), dl, MVT::i8);
} else {
Disp = ImmOp;
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/PowerPC/PPCISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18149,7 +18149,7 @@ PPC::AddrMode PPCTargetLowering::SelectOptimalAddrMode(const SDNode *Parent,
if (Flags & PPC::MOF_RPlusSImm16) {
SDValue Op0 = N.getOperand(0);
SDValue Op1 = N.getOperand(1);
int16_t Imm = cast<ConstantSDNode>(Op1)->getAPIntValue().getZExtValue();
int16_t Imm = cast<ConstantSDNode>(Op1)->getZExtValue();
if (!Align || isAligned(*Align, Imm)) {
Disp = DAG.getTargetConstant(Imm, DL, N.getValueType());
Base = Op0;
Expand Down

0 comments on commit 7bb6d1b

Please sign in to comment.