Skip to content

Commit

Permalink
[Target] Use isNullConstant (NFC)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazutakahirata committed Jan 11, 2024
1 parent 1fe7bdb commit 1e05236
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 22 deletions.
10 changes: 3 additions & 7 deletions llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 2 additions & 6 deletions llvm/lib/Target/AMDGPU/SIISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
13 changes: 4 additions & 9 deletions llvm/lib/Target/MSP430/MSP430ISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1149,15 +1149,10 @@ SDValue MSP430TargetLowering::LowerSETCC(SDValue Op, SelectionDAG &DAG) const {
// but they are different 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);
Expand Down

0 comments on commit 1e05236

Please sign in to comment.