diff --git a/clang/lib/AST/Interp/IntegralAP.h b/clang/lib/AST/Interp/IntegralAP.h index 1f535d420bcd5..6d301bad784af 100644 --- a/clang/lib/AST/Interp/IntegralAP.h +++ b/clang/lib/AST/Interp/IntegralAP.h @@ -248,7 +248,11 @@ template class IntegralAP final { static void shiftRight(const IntegralAP A, const IntegralAP B, unsigned OpBits, IntegralAP *R) { - *R = IntegralAP(A.V.ashr(B.V.getZExtValue())); + unsigned ShiftAmount = B.V.getZExtValue(); + if constexpr (Signed) + *R = IntegralAP(A.V.ashr(ShiftAmount)); + else + *R = IntegralAP(A.V.lshr(ShiftAmount)); } private: