[llvm] 5f2f611 - Fixed more warnings in LLVM produced by -Wbitwise-instead-of-logical
Dávid Bolvanský via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 3 04:58:18 PDT 2021
Author: Dávid Bolvanský
Date: 2021-10-03T13:58:10+02:00
New Revision: 5f2f6118800fe652c102625a6871e3e8b0dcbb6e
URL: https://github.com/llvm/llvm-project/commit/5f2f6118800fe652c102625a6871e3e8b0dcbb6e
DIFF: https://github.com/llvm/llvm-project/commit/5f2f6118800fe652c102625a6871e3e8b0dcbb6e.diff
LOG: Fixed more warnings in LLVM produced by -Wbitwise-instead-of-logical
Added:
Modified:
llvm/include/llvm/Transforms/IPO/Attributor.h
llvm/lib/Analysis/LazyValueInfo.cpp
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/IR/Instruction.cpp
llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
llvm/lib/Transforms/Utils/BuildLibCalls.cpp
llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h
index cfad4e08315b0..59ea407e28145 100644
--- a/llvm/include/llvm/Transforms/IPO/Attributor.h
+++ b/llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -3795,7 +3795,7 @@ struct AAMemoryLocation
/// Return true if we assume that the associated functions has no observable
/// accesses.
bool isAssumedReadNone() const {
- return isAssumed(NO_LOCATIONS) | isAssumedStackOnly();
+ return isAssumed(NO_LOCATIONS) || isAssumedStackOnly();
}
/// Return true if we know that the associated functions has at most
diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp
index 49721d4413382..f8c5155fa51d3 100644
--- a/llvm/lib/Analysis/LazyValueInfo.cpp
+++ b/llvm/lib/Analysis/LazyValueInfo.cpp
@@ -126,7 +126,7 @@ static ValueLatticeElement intersect(const ValueLatticeElement &A,
// Note: An empty range is implicitly converted to unknown or undef depending
// on MayIncludeUndef internally.
return ValueLatticeElement::getRange(
- std::move(Range), /*MayIncludeUndef=*/A.isConstantRangeIncludingUndef() |
+ std::move(Range), /*MayIncludeUndef=*/A.isConstantRangeIncludingUndef() ||
B.isConstantRangeIncludingUndef());
}
@@ -832,7 +832,7 @@ Optional<ValueLatticeElement> LazyValueInfoImpl::solveBlockValueSelect(
};
}();
return ValueLatticeElement::getRange(
- ResultCR, TrueVal.isConstantRangeIncludingUndef() |
+ ResultCR, TrueVal.isConstantRangeIncludingUndef() ||
FalseVal.isConstantRangeIncludingUndef());
}
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index 64664eb24a0d8..75dcc66af2b8a 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -8529,8 +8529,8 @@ bool LLParser::parseOptionalFFlags(FunctionSummary::FFlags &FFlags) {
assert(Lex.getKind() == lltok::kw_funcFlags);
Lex.Lex();
- if (parseToken(lltok::colon, "expected ':' in funcFlags") |
- parseToken(lltok::lparen, "expected '(' in funcFlags"))
+ if ((int)parseToken(lltok::colon, "expected ':' in funcFlags") |
+ (int)parseToken(lltok::lparen, "expected '(' in funcFlags"))
return true;
do {
@@ -8701,8 +8701,8 @@ bool LLParser::parseOptionalVTableFuncs(VTableFuncList &VTableFuncs) {
assert(Lex.getKind() == lltok::kw_vTableFuncs);
Lex.Lex();
- if (parseToken(lltok::colon, "expected ':' in vTableFuncs") |
- parseToken(lltok::lparen, "expected '(' in vTableFuncs"))
+ if ((int)parseToken(lltok::colon, "expected ':' in vTableFuncs") |
+ (int)parseToken(lltok::lparen, "expected '(' in vTableFuncs"))
return true;
IdToIndexMapType IdToIndexMap;
diff --git a/llvm/lib/IR/Instruction.cpp b/llvm/lib/IR/Instruction.cpp
index e91fc1d71c34f..fdeb8bdd8539a 100644
--- a/llvm/lib/IR/Instruction.cpp
+++ b/llvm/lib/IR/Instruction.cpp
@@ -307,20 +307,20 @@ void Instruction::copyIRFlags(const Value *V, bool IncludeWrapFlags) {
if (auto *SrcGEP = dyn_cast<GetElementPtrInst>(V))
if (auto *DestGEP = dyn_cast<GetElementPtrInst>(this))
- DestGEP->setIsInBounds(SrcGEP->isInBounds() | DestGEP->isInBounds());
+ DestGEP->setIsInBounds(SrcGEP->isInBounds() || DestGEP->isInBounds());
}
void Instruction::andIRFlags(const Value *V) {
if (auto *OB = dyn_cast<OverflowingBinaryOperator>(V)) {
if (isa<OverflowingBinaryOperator>(this)) {
- setHasNoSignedWrap(hasNoSignedWrap() & OB->hasNoSignedWrap());
- setHasNoUnsignedWrap(hasNoUnsignedWrap() & OB->hasNoUnsignedWrap());
+ setHasNoSignedWrap(hasNoSignedWrap() && OB->hasNoSignedWrap());
+ setHasNoUnsignedWrap(hasNoUnsignedWrap() && OB->hasNoUnsignedWrap());
}
}
if (auto *PE = dyn_cast<PossiblyExactOperator>(V))
if (isa<PossiblyExactOperator>(this))
- setIsExact(isExact() & PE->isExact());
+ setIsExact(isExact() && PE->isExact());
if (auto *FP = dyn_cast<FPMathOperator>(V)) {
if (isa<FPMathOperator>(this)) {
@@ -332,7 +332,7 @@ void Instruction::andIRFlags(const Value *V) {
if (auto *SrcGEP = dyn_cast<GetElementPtrInst>(V))
if (auto *DestGEP = dyn_cast<GetElementPtrInst>(this))
- DestGEP->setIsInBounds(SrcGEP->isInBounds() & DestGEP->isInBounds());
+ DestGEP->setIsInBounds(SrcGEP->isInBounds() && DestGEP->isInBounds());
}
const char *Instruction::getOpcodeName(unsigned OpCode) {
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
index 951b68b5d742d..9d9267a6ceee8 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
@@ -2208,8 +2208,8 @@ static Instruction *foldFNegIntoConstant(Instruction &I) {
// TODO: We could propagate nsz/ninf from fdiv alone?
FastMathFlags FMF = I.getFastMathFlags();
FastMathFlags OpFMF = FNegOp->getFastMathFlags();
- FDiv->setHasNoSignedZeros(FMF.noSignedZeros() & OpFMF.noSignedZeros());
- FDiv->setHasNoInfs(FMF.noInfs() & OpFMF.noInfs());
+ FDiv->setHasNoSignedZeros(FMF.noSignedZeros() && OpFMF.noSignedZeros());
+ FDiv->setHasNoInfs(FMF.noInfs() && OpFMF.noInfs());
return FDiv;
}
// With NSZ [ counter-example with -0.0: -(-0.0 + 0.0) != 0.0 + -0.0 ]:
diff --git a/llvm/lib/Transforms/Utils/BuildLibCalls.cpp b/llvm/lib/Transforms/Utils/BuildLibCalls.cpp
index adf6a850b06a7..9579353989722 100644
--- a/llvm/lib/Transforms/Utils/BuildLibCalls.cpp
+++ b/llvm/lib/Transforms/Utils/BuildLibCalls.cpp
@@ -174,7 +174,10 @@ static bool setArgNoUndef(Function &F, unsigned ArgNo) {
}
static bool setRetAndArgsNoUndef(Function &F) {
- return setRetNoUndef(F) | setArgsNoUndef(F);
+ bool UndefAdded = false;
+ UndefAdded |= setRetNoUndef(F);
+ UndefAdded |= setArgsNoUndef(F);
+ return UndefAdded;
}
static bool setReturnedArg(Function &F, unsigned ArgNo) {
diff --git a/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp b/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
index 1b5208824913b..5a4a2f0924f68 100644
--- a/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
@@ -1072,9 +1072,12 @@ bool Vectorizer::vectorizeStoreChain(
if (ChainSize > VF || (VF != TargetVF && TargetVF < ChainSize)) {
LLVM_DEBUG(dbgs() << "LSV: Chain doesn't match with the vector factor."
" Creating two separate arrays.\n");
- return vectorizeStoreChain(Chain.slice(0, TargetVF),
- InstructionsProcessed) |
- vectorizeStoreChain(Chain.slice(TargetVF), InstructionsProcessed);
+ bool Vectorized = false;
+ Vectorized |=
+ vectorizeStoreChain(Chain.slice(0, TargetVF), InstructionsProcessed);
+ Vectorized |=
+ vectorizeStoreChain(Chain.slice(TargetVF), InstructionsProcessed);
+ return Vectorized;
}
LLVM_DEBUG({
@@ -1091,8 +1094,10 @@ bool Vectorizer::vectorizeStoreChain(
if (accessIsMisaligned(SzInBytes, AS, Alignment)) {
if (S0->getPointerAddressSpace() != DL.getAllocaAddrSpace()) {
auto Chains = splitOddVectorElts(Chain, Sz);
- return vectorizeStoreChain(Chains.first, InstructionsProcessed) |
- vectorizeStoreChain(Chains.second, InstructionsProcessed);
+ bool Vectorized = false;
+ Vectorized |= vectorizeStoreChain(Chains.first, InstructionsProcessed);
+ Vectorized |= vectorizeStoreChain(Chains.second, InstructionsProcessed);
+ return Vectorized;
}
Align NewAlign = getOrEnforceKnownAlignment(S0->getPointerOperand(),
@@ -1106,8 +1111,10 @@ bool Vectorizer::vectorizeStoreChain(
if (!TTI.isLegalToVectorizeStoreChain(SzInBytes, Alignment, AS)) {
auto Chains = splitOddVectorElts(Chain, Sz);
- return vectorizeStoreChain(Chains.first, InstructionsProcessed) |
- vectorizeStoreChain(Chains.second, InstructionsProcessed);
+ bool Vectorized = false;
+ Vectorized |= vectorizeStoreChain(Chains.first, InstructionsProcessed);
+ Vectorized |= vectorizeStoreChain(Chains.second, InstructionsProcessed);
+ return Vectorized;
}
BasicBlock::iterator First, Last;
@@ -1224,8 +1231,12 @@ bool Vectorizer::vectorizeLoadChain(
if (ChainSize > VF || (VF != TargetVF && TargetVF < ChainSize)) {
LLVM_DEBUG(dbgs() << "LSV: Chain doesn't match with the vector factor."
" Creating two separate arrays.\n");
- return vectorizeLoadChain(Chain.slice(0, TargetVF), InstructionsProcessed) |
- vectorizeLoadChain(Chain.slice(TargetVF), InstructionsProcessed);
+ bool Vectorized = false;
+ Vectorized |=
+ vectorizeLoadChain(Chain.slice(0, TargetVF), InstructionsProcessed);
+ Vectorized |=
+ vectorizeLoadChain(Chain.slice(TargetVF), InstructionsProcessed);
+ return Vectorized;
}
// We won't try again to vectorize the elements of the chain, regardless of
@@ -1236,8 +1247,10 @@ bool Vectorizer::vectorizeLoadChain(
if (accessIsMisaligned(SzInBytes, AS, Alignment)) {
if (L0->getPointerAddressSpace() != DL.getAllocaAddrSpace()) {
auto Chains = splitOddVectorElts(Chain, Sz);
- return vectorizeLoadChain(Chains.first, InstructionsProcessed) |
- vectorizeLoadChain(Chains.second, InstructionsProcessed);
+ bool Vectorized = false;
+ Vectorized |= vectorizeLoadChain(Chains.first, InstructionsProcessed);
+ Vectorized |= vectorizeLoadChain(Chains.second, InstructionsProcessed);
+ return Vectorized;
}
Align NewAlign = getOrEnforceKnownAlignment(L0->getPointerOperand(),
@@ -1251,8 +1264,10 @@ bool Vectorizer::vectorizeLoadChain(
if (!TTI.isLegalToVectorizeLoadChain(SzInBytes, Alignment, AS)) {
auto Chains = splitOddVectorElts(Chain, Sz);
- return vectorizeLoadChain(Chains.first, InstructionsProcessed) |
- vectorizeLoadChain(Chains.second, InstructionsProcessed);
+ bool Vectorized = false;
+ Vectorized |= vectorizeLoadChain(Chains.first, InstructionsProcessed);
+ Vectorized |= vectorizeLoadChain(Chains.second, InstructionsProcessed);
+ return Vectorized;
}
LLVM_DEBUG({
More information about the llvm-commits
mailing list