Skip to content

Commit

Permalink
[AMDGPU] Use isNullConstant (NFC)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazutakahirata committed Dec 8, 2023
1 parent c8616c7 commit 28a78e2
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2334,9 +2334,8 @@ static SDValue combineBallotPattern(SDValue VCMP, bool &Negate) {
// Note that ballot doesn't use SETEQ condition but its easy to support it
// here for completeness, so in this case Negate is set true on return.
auto VCMP_CC = cast<CondCodeSDNode>(VCMP.getOperand(2))->get();
auto *VCMP_CRHS = dyn_cast<ConstantSDNode>(VCMP.getOperand(1));
if ((VCMP_CC == ISD::SETEQ || VCMP_CC == ISD::SETNE) && VCMP_CRHS &&
VCMP_CRHS->isZero()) {
if ((VCMP_CC == ISD::SETEQ || VCMP_CC == ISD::SETNE) &&
isNullConstant(VCMP.getOperand(1))) {

auto Cond = VCMP.getOperand(0);
if (ISD::isExtOpcode(Cond->getOpcode())) // Skip extension.
Expand Down Expand Up @@ -2370,8 +2369,8 @@ void AMDGPUDAGToDAGISel::SelectBRCOND(SDNode *N) {
Cond->getOperand(0)->getOpcode() == AMDGPUISD::SETCC) {
SDValue VCMP = Cond->getOperand(0);
auto CC = cast<CondCodeSDNode>(Cond->getOperand(2))->get();
auto *CRHS = dyn_cast<ConstantSDNode>(Cond->getOperand(1));
if ((CC == ISD::SETEQ || CC == ISD::SETNE) && CRHS && CRHS->isZero() &&
if ((CC == ISD::SETEQ || CC == ISD::SETNE) &&
isNullConstant(Cond->getOperand(1)) &&
// TODO: make condition below an assert after fixing ballot bitwidth.
VCMP.getValueType().getSizeInBits() == ST->getWavefrontSize()) {
// %VCMP = i(WaveSize) AMDGPUISD::SETCC ...
Expand Down

0 comments on commit 28a78e2

Please sign in to comment.