[PATCH] D24311: Implement MS _rot intrinsics
David Majnemer via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 7 21:20:35 PDT 2016
majnemer added inline comments.
================
Comment at: lib/AST/ExprConstant.cpp:7024-7050
@@ -7023,1 +7023,29 @@
+ case Builtin::BI_rotl8:
+ case Builtin::BI_rotl16:
+ case Builtin::BI_rotl:
+ case Builtin::BI_lrotl:
+ case Builtin::BI_rotl64: {
+ APSInt Val, Shift;
+ if (!EvaluateInteger(E->getArg(0), Val, Info) ||
+ !EvaluateInteger(E->getArg(1), Shift, Info))
+ return false;
+
+ APSInt BitWidth(llvm::APInt(32, Val.getBitWidth()));
+ return Success(Val.rotl(Shift % BitWidth), E);
+ }
+
+ case Builtin::BI_rotr8:
+ case Builtin::BI_rotr16:
+ case Builtin::BI_rotr:
+ case Builtin::BI_lrotr:
+ case Builtin::BI_rotr64: {
+ APSInt Val, Shift;
+ if (!EvaluateInteger(E->getArg(0), Val, Info) ||
+ !EvaluateInteger(E->getArg(1), Shift, Info))
+ return false;
+
+ APSInt BitWidth(llvm::APInt(32, Val.getBitWidth()));
+ return Success(Val.rotr(Shift % BitWidth), E);
+ }
+
----------------
Any reason why we need this?
Given:
#include <intrin.h>
constexpr int x = _rotl8(1, 2);
MSVC 2015 reports:
error C2131: expression did not evaluate to a constant
https://reviews.llvm.org/D24311
More information about the cfe-commits
mailing list