diff options
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp')
| -rw-r--r-- | clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp b/clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp index 96f5d7c44baf..01d87b02fcdb 100644 --- a/clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp +++ b/clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp @@ -283,10 +283,10 @@ static bool shouldCompletelyUnroll(const Stmt *LoopStmt, ASTContext &ASTCtx, llvm::APInt InitNum = Matches[0].getNodeAs<IntegerLiteral>("initNum")->getValue(); auto CondOp = Matches[0].getNodeAs<BinaryOperator>("conditionOperator"); - if (InitNum.getBitWidth() != BoundNum.getBitWidth()) { - InitNum = InitNum.zext(BoundNum.getBitWidth()); - BoundNum = BoundNum.zext(InitNum.getBitWidth()); - } + unsigned MaxWidth = std::max(InitNum.getBitWidth(), BoundNum.getBitWidth()); + + InitNum = InitNum.zext(MaxWidth); + BoundNum = BoundNum.zext(MaxWidth); if (CondOp->getOpcode() == BO_GE || CondOp->getOpcode() == BO_LE) maxStep = (BoundNum - InitNum + 1).abs().getZExtValue(); |
