[llvm] 53ead52 - [Target] Use isNullConstant and isOneConstant (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 10 18:23:13 PDT 2023
Author: Kazu Hirata
Date: 2023-04-10T18:23:07-07:00
New Revision: 53ead5215be023ba8087a5e0cf611319b4fbdb79
URL: https://github.com/llvm/llvm-project/commit/53ead5215be023ba8087a5e0cf611319b4fbdb79
DIFF: https://github.com/llvm/llvm-project/commit/53ead5215be023ba8087a5e0cf611319b4fbdb79.diff
LOG: [Target] Use isNullConstant and isOneConstant (NFC)
Added:
Modified:
llvm/lib/Target/AMDGPU/SIISelLowering.cpp
llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
index d97719ff98b4b..9a483283882b7 100644
--- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -11362,8 +11362,7 @@ SDValue SITargetLowering::performAddCarrySubCarryCombine(SDNode *N,
if (N->getValueType(0) != MVT::i32)
return SDValue();
- auto C = dyn_cast<ConstantSDNode>(N->getOperand(1));
- if (!C || C->getZExtValue() != 0)
+ if (!isNullConstant(N->getOperand(1)))
return SDValue();
SelectionDAG &DAG = DCI.DAG;
diff --git a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
index a62dde47757ba..291c8c40bea02 100644
--- a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
@@ -5722,21 +5722,18 @@ void PPCDAGToDAGISel::Select(SDNode *N) {
}
// Handle the setcc cases here. select_cc lhs, 0, 1, 0, cc
- if (!isPPC64)
- if (ConstantSDNode *N1C = dyn_cast<ConstantSDNode>(N->getOperand(1)))
- if (ConstantSDNode *N2C = dyn_cast<ConstantSDNode>(N->getOperand(2)))
- if (ConstantSDNode *N3C = dyn_cast<ConstantSDNode>(N->getOperand(3)))
- if (N1C->isZero() && N3C->isZero() && N2C->getZExtValue() == 1ULL &&
- CC == ISD::SETNE &&
- // FIXME: Implement this optzn for PPC64.
- N->getValueType(0) == MVT::i32) {
- SDNode *Tmp =
- CurDAG->getMachineNode(PPC::ADDIC, dl, MVT::i32, MVT::Glue,
- N->getOperand(0), getI32Imm(~0U, dl));
- CurDAG->SelectNodeTo(N, PPC::SUBFE, MVT::i32, SDValue(Tmp, 0),
- N->getOperand(0), SDValue(Tmp, 1));
- return;
- }
+ if (!isPPC64 && isNullConstant(N->getOperand(1)) &&
+ isOneConstant(N->getOperand(2)) && isNullConstant(N->getOperand(3)) &&
+ CC == ISD::SETNE &&
+ // FIXME: Implement this optzn for PPC64.
+ N->getValueType(0) == MVT::i32) {
+ SDNode *Tmp =
+ CurDAG->getMachineNode(PPC::ADDIC, dl, MVT::i32, MVT::Glue,
+ N->getOperand(0), getI32Imm(~0U, dl));
+ CurDAG->SelectNodeTo(N, PPC::SUBFE, MVT::i32, SDValue(Tmp, 0),
+ N->getOperand(0), SDValue(Tmp, 1));
+ return;
+ }
SDValue CCReg = SelectCC(N->getOperand(0), N->getOperand(1), CC, dl);
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 715a921b61a4b..1c1ccf8d538f5 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -14557,10 +14557,9 @@ void RISCVTargetLowering::LowerAsmOperandForConstraint(
return;
case 'J':
// Validate & create an integer zero operand.
- if (auto *C = dyn_cast<ConstantSDNode>(Op))
- if (C->getZExtValue() == 0)
- Ops.push_back(
- DAG.getTargetConstant(0, SDLoc(Op), Subtarget.getXLenVT()));
+ if (isNullConstant(Op))
+ Ops.push_back(
+ DAG.getTargetConstant(0, SDLoc(Op), Subtarget.getXLenVT()));
return;
case 'K':
// Validate & create a 5-bit unsigned immediate operand.
diff --git a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
index 7ff35a3c8cec3..cd6bf0c3729db 100644
--- a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
+++ b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
@@ -1715,23 +1715,21 @@ bool X86DAGToDAGISel::matchLoadInAddress(LoadSDNode *N, X86ISelAddressMode &AM,
// zero-extended to 64 bits and then added it to the base address, which gives
// unwanted results when the register holds a negative value.
// For more information see http://people.redhat.com/drepper/tls.pdf
- if (auto *C = dyn_cast<ConstantSDNode>(Address)) {
- if (C->getSExtValue() == 0 && AM.Segment.getNode() == nullptr &&
- !IndirectTlsSegRefs &&
- (Subtarget->isTargetGlibc() || Subtarget->isTargetAndroid() ||
- Subtarget->isTargetFuchsia())) {
- if (Subtarget->isTarget64BitILP32() && !AllowSegmentRegForX32)
- return true;
- switch (N->getPointerInfo().getAddrSpace()) {
- case X86AS::GS:
- AM.Segment = CurDAG->getRegister(X86::GS, MVT::i16);
- return false;
- case X86AS::FS:
- AM.Segment = CurDAG->getRegister(X86::FS, MVT::i16);
- return false;
+ if (isNullConstant(Address) && AM.Segment.getNode() == nullptr &&
+ !IndirectTlsSegRefs &&
+ (Subtarget->isTargetGlibc() || Subtarget->isTargetAndroid() ||
+ Subtarget->isTargetFuchsia())) {
+ if (Subtarget->isTarget64BitILP32() && !AllowSegmentRegForX32)
+ return true;
+ switch (N->getPointerInfo().getAddrSpace()) {
+ case X86AS::GS:
+ AM.Segment = CurDAG->getRegister(X86::GS, MVT::i16);
+ return false;
+ case X86AS::FS:
+ AM.Segment = CurDAG->getRegister(X86::FS, MVT::i16);
+ return false;
// Address space X86AS::SS is not handled here, because it is not used to
// address TLS areas.
- }
}
}
More information about the llvm-commits
mailing list