[llvm] 1e05236 - [Target] Use isNullConstant (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 10 20:25:31 PST 2024
Author: Kazu Hirata
Date: 2024-01-10T20:25:24-08:00
New Revision: 1e05236dbdf6f1b27b5e68c3948fec7deea4e3dc
URL: https://github.com/llvm/llvm-project/commit/1e05236dbdf6f1b27b5e68c3948fec7deea4e3dc
DIFF: https://github.com/llvm/llvm-project/commit/1e05236dbdf6f1b27b5e68c3948fec7deea4e3dc.diff
LOG: [Target] Use isNullConstant (NFC)
Added:
Modified:
llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
llvm/lib/Target/AMDGPU/SIISelLowering.cpp
llvm/lib/Target/MSP430/MSP430ISelLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp b/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
index 119aa80b9bb5d5..41462d7a133ed1 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
@@ -1579,13 +1579,9 @@ bool AMDGPUDAGToDAGISel::SelectMUBUFOffset(SDValue Addr, SDValue &SRsrc,
bool AMDGPUDAGToDAGISel::SelectBUFSOffset(SDValue ByteOffsetNode,
SDValue &SOffset) const {
- if (Subtarget->hasRestrictedSOffset()) {
- if (auto SOffsetConst = dyn_cast<ConstantSDNode>(ByteOffsetNode)) {
- if (SOffsetConst->isZero()) {
- SOffset = CurDAG->getRegister(AMDGPU::SGPR_NULL, MVT::i32);
- return true;
- }
- }
+ if (Subtarget->hasRestrictedSOffset() && isNullConstant(ByteOffsetNode)) {
+ SOffset = CurDAG->getRegister(AMDGPU::SGPR_NULL, MVT::i32);
+ return true;
}
SOffset = ByteOffsetNode;
diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
index 6ddc7e864fb23c..5a9222e9158861 100644
--- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -8181,12 +8181,8 @@ SDValue SITargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op,
// SGPR_NULL to avoid generating an extra s_mov with zero.
static SDValue selectSOffset(SDValue SOffset, SelectionDAG &DAG,
const GCNSubtarget *Subtarget) {
- if (Subtarget->hasRestrictedSOffset())
- if (auto SOffsetConst = dyn_cast<ConstantSDNode>(SOffset)) {
- if (SOffsetConst->isZero()) {
- return DAG.getRegister(AMDGPU::SGPR_NULL, MVT::i32);
- }
- }
+ if (Subtarget->hasRestrictedSOffset() && isNullConstant(SOffset))
+ return DAG.getRegister(AMDGPU::SGPR_NULL, MVT::i32);
return SOffset;
}
diff --git a/llvm/lib/Target/MSP430/MSP430ISelLowering.cpp b/llvm/lib/Target/MSP430/MSP430ISelLowering.cpp
index e68904863cfc7a..fc066f001316d4 100644
--- a/llvm/lib/Target/MSP430/MSP430ISelLowering.cpp
+++ b/llvm/lib/Target/MSP430/MSP430ISelLowering.cpp
@@ -1149,15 +1149,10 @@ SDValue MSP430TargetLowering::LowerSETCC(SDValue Op, SelectionDAG &DAG) const {
// but they are
diff erent from CMP.
// FIXME: since we're doing a post-processing, use a pseudoinstr here, so
// lowering & isel wouldn't diverge.
- bool andCC = false;
- if (ConstantSDNode *RHSC = dyn_cast<ConstantSDNode>(RHS)) {
- if (RHSC->isZero() && LHS.hasOneUse() &&
- (LHS.getOpcode() == ISD::AND ||
- (LHS.getOpcode() == ISD::TRUNCATE &&
- LHS.getOperand(0).getOpcode() == ISD::AND))) {
- andCC = true;
- }
- }
+ bool andCC = isNullConstant(RHS) && LHS.hasOneUse() &&
+ (LHS.getOpcode() == ISD::AND ||
+ (LHS.getOpcode() == ISD::TRUNCATE &&
+ LHS.getOperand(0).getOpcode() == ISD::AND));
ISD::CondCode CC = cast<CondCodeSDNode>(Op.getOperand(2))->get();
SDValue TargetCC;
SDValue Flag = EmitCMP(LHS, RHS, TargetCC, CC, dl, DAG);
More information about the llvm-commits
mailing list