From: Kazu Hirata Date: Tue, 11 Apr 2023 01:23:07 +0000 (-0700) Subject: [Target] Use isNullConstant and isOneConstant (NFC) X-Git-Tag: upstream/17.0.6~12114 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=53ead5215be023ba8087a5e0cf611319b4fbdb79;p=platform%2Fupstream%2Fllvm.git [Target] Use isNullConstant and isOneConstant (NFC) --- diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp index d97719f..9a48328 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(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 a62dde4..291c8c4 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(N->getOperand(1))) - if (ConstantSDNode *N2C = dyn_cast(N->getOperand(2))) - if (ConstantSDNode *N3C = dyn_cast(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 715a921..1c1ccf8 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(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 7ff35a3..cd6bf0c 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(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. - } } }