================
@@ -283,10 +283,12 @@ 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());
----------------
steakhal wrote:

Have you checked if there is a utility achieving this for us? Like the 
`APSIntType` type? (IDK, I rarely ever use it)
I also wonder if we actually need to operate at an APSInt level, maybe we could 
just convert both of these into int64 and do the math on those.

Is zero extension is actually correct in semantics? What if the `InitNum` was 
negative, léike `-1`, then shouldn't we use sign extension?

https://github.com/llvm/llvm-project/pull/121203
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to