From cfdba8b7400746250daf9f9557d3dfca3dadf7c6 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Fri, 13 Jan 2023 16:28:44 -0800 Subject: [PATCH] Fix some -Wconstant-conversion warnings for future Clang (D139114) --- llvm/include/llvm/Analysis/DependenceAnalysis.h | 18 ++++++++++-------- llvm/lib/Analysis/DependenceAnalysis.cpp | 12 ++++++------ llvm/lib/Support/UnicodeNameToCodepoint.cpp | 2 +- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/llvm/include/llvm/Analysis/DependenceAnalysis.h b/llvm/include/llvm/Analysis/DependenceAnalysis.h index 0ea315a..327315f 100644 --- a/llvm/include/llvm/Analysis/DependenceAnalysis.h +++ b/llvm/include/llvm/Analysis/DependenceAnalysis.h @@ -82,14 +82,16 @@ namespace llvm { /// has a direction (or perhaps a union of several directions), and /// perhaps a distance. struct DVEntry { - enum { NONE = 0, - LT = 1, - EQ = 2, - LE = 3, - GT = 4, - NE = 5, - GE = 6, - ALL = 7 }; + enum : unsigned char { + NONE = 0, + LT = 1, + EQ = 2, + LE = 3, + GT = 4, + NE = 5, + GE = 6, + ALL = 7 + }; unsigned char Direction : 3; // Init to ALL, then refine. bool Scalar : 1; // Init to true. bool PeelFirst : 1; // Peeling the first iteration will break dependence. diff --git a/llvm/lib/Analysis/DependenceAnalysis.cpp b/llvm/lib/Analysis/DependenceAnalysis.cpp index 92d29a5..1bce9aa 100644 --- a/llvm/lib/Analysis/DependenceAnalysis.cpp +++ b/llvm/lib/Analysis/DependenceAnalysis.cpp @@ -1379,8 +1379,8 @@ bool DependenceInfo::weakCrossingSIVtest( LLVM_DEBUG(dbgs() << "\t Delta = " << *Delta << "\n"); NewConstraint.setLine(Coeff, Coeff, Delta, CurLoop); if (Delta->isZero()) { - Result.DV[Level].Direction &= unsigned(~Dependence::DVEntry::LT); - Result.DV[Level].Direction &= unsigned(~Dependence::DVEntry::GT); + Result.DV[Level].Direction &= ~Dependence::DVEntry::LT; + Result.DV[Level].Direction &= ~Dependence::DVEntry::GT; ++WeakCrossingSIVsuccesses; if (!Result.DV[Level].Direction) { ++WeakCrossingSIVindependence; @@ -1439,8 +1439,8 @@ bool DependenceInfo::weakCrossingSIVtest( } if (isKnownPredicate(CmpInst::ICMP_EQ, Delta, ML)) { // i = i' = UB - Result.DV[Level].Direction &= unsigned(~Dependence::DVEntry::LT); - Result.DV[Level].Direction &= unsigned(~Dependence::DVEntry::GT); + Result.DV[Level].Direction &= ~Dependence::DVEntry::LT; + Result.DV[Level].Direction &= ~Dependence::DVEntry::GT; ++WeakCrossingSIVsuccesses; if (!Result.DV[Level].Direction) { ++WeakCrossingSIVindependence; @@ -1473,7 +1473,7 @@ bool DependenceInfo::weakCrossingSIVtest( LLVM_DEBUG(dbgs() << "\t Remainder = " << Remainder << "\n"); if (Remainder != 0) { // Equal direction isn't possible - Result.DV[Level].Direction &= unsigned(~Dependence::DVEntry::EQ); + Result.DV[Level].Direction &= ~Dependence::DVEntry::EQ; ++WeakCrossingSIVsuccesses; } return false; @@ -2557,7 +2557,7 @@ bool DependenceInfo::gcdMIVtest(const SCEV *Src, const SCEV *Dst, LLVM_DEBUG(dbgs() << "\tRemainder = " << Remainder << "\n"); if (Remainder != 0) { unsigned Level = mapSrcLoop(CurLoop); - Result.DV[Level - 1].Direction &= unsigned(~Dependence::DVEntry::EQ); + Result.DV[Level - 1].Direction &= ~Dependence::DVEntry::EQ; Improved = true; } } diff --git a/llvm/lib/Support/UnicodeNameToCodepoint.cpp b/llvm/lib/Support/UnicodeNameToCodepoint.cpp index df71be3..accebf1 100644 --- a/llvm/lib/Support/UnicodeNameToCodepoint.cpp +++ b/llvm/lib/Support/UnicodeNameToCodepoint.cpp @@ -105,7 +105,7 @@ static Node readNode(uint32_t Offset, const Node *Parent = nullptr) { uint8_t H = UnicodeNameToCodepointIndex[Offset++]; N.HasSibling = H & 0x80; bool HasChildren = H & 0x40; - H &= ~uint8_t(0xC0); + H &= uint8_t(~0xC0); if (HasChildren) { N.ChildrenOffset = (H << 16); N.ChildrenOffset |= -- 2.7.4