Skip to content

Conversation

rdez13
Copy link
Contributor

@rdez13 rdez13 commented Oct 6, 2025

Fixes #162046

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Oct 6, 2025
@llvmbot
Copy link
Member

llvmbot commented Oct 6, 2025

@llvm/pr-subscribers-clang

Author: None (rdez13)

Changes

Fixes #162046


Full diff: https://github.com/llvm/llvm-project/pull/162113.diff

1 Files Affected:

  • (modified) clang/lib/AST/ExprConstant.cpp (+2-2)
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 7bf28d988f405..a9fedc1df56ce 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -14265,7 +14265,7 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
         !EvaluateInteger(E->getArg(1), Amt, Info))
       return false;
 
-    return Success(Val.rotl(Amt.urem(Val.getBitWidth())), E);
+    return Success(Val.rotl(Amt), E);
   }
 
   case Builtin::BI__builtin_rotateright8:
@@ -14282,7 +14282,7 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
         !EvaluateInteger(E->getArg(1), Amt, Info))
       return false;
 
-    return Success(Val.rotr(Amt.urem(Val.getBitWidth())), E);
+    return Success(Val.rotr(Amt), E);
   }
 
   case Builtin::BI__builtin_elementwise_add_sat: {

@rdez13
Copy link
Contributor Author

rdez13 commented Oct 6, 2025

Hey @RKSimon, can I please get a review. Thanks

@RKSimon RKSimon requested review from RKSimon and tbaederr October 6, 2025 17:38
@RKSimon RKSimon changed the title llvm#162046 removed urem() call in rotate builtins, called rotl/rotr directly [clang][bytecode] VisitBuiltinCallExpr - remove urem() call in rotate builtins, called rotl/rotr directly Oct 6, 2025
Copy link
Collaborator

@RKSimon RKSimon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@RKSimon RKSimon enabled auto-merge (squash) October 6, 2025 19:17
@RKSimon RKSimon merged commit 24d41c1 into llvm:main Oct 6, 2025
9 checks passed
@rdez13
Copy link
Contributor Author

rdez13 commented Oct 6, 2025

Thanks for the review and merge!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[clang] ExprConstant - VisitBuiltinCallExpr - rotation folds don't require explicit APInt::urem calls
3 participants