Skip to content

[AMDGPU] Simplify conditional expressions. NFC. #129228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,8 @@ bool AMDGPUCodeGenPrepareImpl::isSigned(const BinaryOperator &I) const {
}

bool AMDGPUCodeGenPrepareImpl::isSigned(const SelectInst &I) const {
return isa<ICmpInst>(I.getOperand(0)) ?
cast<ICmpInst>(I.getOperand(0))->isSigned() : false;
return isa<ICmpInst>(I.getOperand(0)) &&
cast<ICmpInst>(I.getOperand(0))->isSigned();
}

bool AMDGPUCodeGenPrepareImpl::needsPromotionToI32(const Type *T) const {
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ bool AMDGPUTargetLowering::isNarrowingProfitable(SDNode *N, EVT SrcVT,
case ISD::SETCC:
case ISD::SELECT:
if (Subtarget->has16BitInsts() &&
(DestVT.isVector() ? !Subtarget->hasVOP3PInsts() : true)) {
(!DestVT.isVector() || !Subtarget->hasVOP3PInsts())) {
// Don't narrow back down to i16 if promoted to i32 already.
if (!N->isDivergent() && DestVT.isInteger() &&
DestVT.getScalarSizeInBits() > 1 &&
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2003,9 +2003,9 @@ static bool parseTexFail(uint64_t TexFailCtrl, bool &TFE, bool &LWE,
if (TexFailCtrl)
IsTexFail = true;

TFE = (TexFailCtrl & 0x1) ? true : false;
TFE = TexFailCtrl & 0x1;
TexFailCtrl &= ~(uint64_t)0x1;
LWE = (TexFailCtrl & 0x2) ? true : false;
LWE = TexFailCtrl & 0x2;
TexFailCtrl &= ~(uint64_t)0x2;

return TexFailCtrl == 0;
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ bool AMDGPUPromoteAllocaImpl::run(Function &F, bool PromoteToLDS) {

MaxVGPRs = getMaxVGPRs(TM, F);

bool SufficientLDS = PromoteToLDS ? hasSufficientLocalMem(F) : false;
bool SufficientLDS = PromoteToLDS && hasSufficientLocalMem(F);

// Use up to 1/4 of available register budget for vectorization.
// FIXME: Increase the limit for whole function budgets? Perhaps x2?
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AMDGPU/AMDGPUSwLowerLDS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ void AMDGPUSwLowerLDS::buildSwDynLDSGlobal(Function *Func) {

void AMDGPUSwLowerLDS::populateSwLDSAttributeAndMetadata(Function *Func) {
auto &LDSParams = FuncLDSAccessInfo.KernelToLDSParametersMap[Func];
bool IsDynLDSUsed = LDSParams.SwDynLDS ? true : false;
bool IsDynLDSUsed = LDSParams.SwDynLDS;
uint32_t Offset = LDSParams.LDSSize;
recordLDSAbsoluteAddress(M, LDSParams.SwLDS, 0);
addLDSSizeAttribute(Func, Offset, IsDynLDSUsed);
Expand Down
6 changes: 2 additions & 4 deletions llvm/lib/Target/AMDGPU/SIISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15334,10 +15334,8 @@ SDNode *SITargetLowering::adjustWritemask(MachineSDNode *&Node,
unsigned NewDmask = 0;
unsigned TFEIdx = AMDGPU::getNamedOperandIdx(Opcode, AMDGPU::OpName::tfe) - 1;
unsigned LWEIdx = AMDGPU::getNamedOperandIdx(Opcode, AMDGPU::OpName::lwe) - 1;
bool UsesTFC = ((int(TFEIdx) >= 0 && Node->getConstantOperandVal(TFEIdx)) ||
(int(LWEIdx) >= 0 && Node->getConstantOperandVal(LWEIdx)))
? true
: false;
bool UsesTFC = (int(TFEIdx) >= 0 && Node->getConstantOperandVal(TFEIdx)) ||
(int(LWEIdx) >= 0 && Node->getConstantOperandVal(LWEIdx));
unsigned TFCLane = 0;
bool HasChain = Node->getNumValues() > 1;

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3500,7 +3500,7 @@ bool SIRegisterInfo::isSGPRReg(const MachineRegisterInfo &MRI,
RC = MRI.getRegClass(Reg);
else
RC = getPhysRegBaseClass(Reg);
return RC ? isSGPRClass(RC) : false;
return RC && isSGPRClass(RC);
}

const TargetRegisterClass *
Expand Down
30 changes: 15 additions & 15 deletions llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,17 +459,17 @@ int getMTBUFElements(unsigned Opc) {

bool getMTBUFHasVAddr(unsigned Opc) {
const MTBUFInfo *Info = getMTBUFOpcodeHelper(Opc);
return Info ? Info->has_vaddr : false;
return Info && Info->has_vaddr;
}

bool getMTBUFHasSrsrc(unsigned Opc) {
const MTBUFInfo *Info = getMTBUFOpcodeHelper(Opc);
return Info ? Info->has_srsrc : false;
return Info && Info->has_srsrc;
}

bool getMTBUFHasSoffset(unsigned Opc) {
const MTBUFInfo *Info = getMTBUFOpcodeHelper(Opc);
return Info ? Info->has_soffset : false;
return Info && Info->has_soffset;
}

int getMUBUFBaseOpcode(unsigned Opc) {
Expand All @@ -489,47 +489,47 @@ int getMUBUFElements(unsigned Opc) {

bool getMUBUFHasVAddr(unsigned Opc) {
const MUBUFInfo *Info = getMUBUFOpcodeHelper(Opc);
return Info ? Info->has_vaddr : false;
return Info && Info->has_vaddr;
}

bool getMUBUFHasSrsrc(unsigned Opc) {
const MUBUFInfo *Info = getMUBUFOpcodeHelper(Opc);
return Info ? Info->has_srsrc : false;
return Info && Info->has_srsrc;
}

bool getMUBUFHasSoffset(unsigned Opc) {
const MUBUFInfo *Info = getMUBUFOpcodeHelper(Opc);
return Info ? Info->has_soffset : false;
return Info && Info->has_soffset;
}

bool getMUBUFIsBufferInv(unsigned Opc) {
const MUBUFInfo *Info = getMUBUFOpcodeHelper(Opc);
return Info ? Info->IsBufferInv : false;
return Info && Info->IsBufferInv;
}

bool getMUBUFTfe(unsigned Opc) {
const MUBUFInfo *Info = getMUBUFOpcodeHelper(Opc);
return Info ? Info->tfe : false;
return Info && Info->tfe;
}

bool getSMEMIsBuffer(unsigned Opc) {
const SMInfo *Info = getSMEMOpcodeHelper(Opc);
return Info ? Info->IsBuffer : false;
return Info && Info->IsBuffer;
}

bool getVOP1IsSingle(unsigned Opc) {
const VOPInfo *Info = getVOP1OpcodeHelper(Opc);
return Info ? Info->IsSingle : true;
return !Info || Info->IsSingle;
}

bool getVOP2IsSingle(unsigned Opc) {
const VOPInfo *Info = getVOP2OpcodeHelper(Opc);
return Info ? Info->IsSingle : true;
return !Info || Info->IsSingle;
}

bool getVOP3IsSingle(unsigned Opc) {
const VOPInfo *Info = getVOP3OpcodeHelper(Opc);
return Info ? Info->IsSingle : true;
return !Info || Info->IsSingle;
}

bool isVOPC64DPP(unsigned Opc) {
Expand All @@ -540,12 +540,12 @@ bool isVOPCAsmOnly(unsigned Opc) { return isVOPCAsmOnlyOpcodeHelper(Opc); }

bool getMAIIsDGEMM(unsigned Opc) {
const MAIInstInfo *Info = getMAIInstInfoHelper(Opc);
return Info ? Info->is_dgemm : false;
return Info && Info->is_dgemm;
}

bool getMAIIsGFX940XDL(unsigned Opc) {
const MAIInstInfo *Info = getMAIInstInfoHelper(Opc);
return Info ? Info->is_gfx940_xdl : false;
return Info && Info->is_gfx940_xdl;
}

uint8_t mfmaScaleF8F6F4FormatToNumRegs(unsigned EncodingVal) {
Expand Down Expand Up @@ -666,7 +666,7 @@ bool isGenericAtomic(unsigned Opc) {

bool isTrue16Inst(unsigned Opc) {
const VOPTrue16Info *Info = getTrue16OpcodeHelper(Opc);
return Info ? Info->IsTrue16 : false;
return Info && Info->IsTrue16;
}

FPType getFPDstSelType(unsigned Opc) {
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AMDGPU/Utils/AMDKernelCodeTUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ bool AMDGPUMCKernelCodeT::ParseKernelCodeT(StringRef ID, MCAsmParser &MCParser,
return true;
}
auto Parser = getParserTable()[Idx];
return Parser ? Parser(*this, MCParser, Err) : false;
return Parser && Parser(*this, MCParser, Err);
}

void AMDGPUMCKernelCodeT::EmitKernelCodeT(raw_ostream &OS, MCContext &Ctx,
Expand Down
Loading