diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h index 302fdd3955502..d3e645d30094d 100644 --- a/llvm/include/llvm/ADT/APInt.h +++ b/llvm/include/llvm/ADT/APInt.h @@ -19,7 +19,6 @@ #include "llvm/Support/MathExtras.h" #include #include -#include #include #include @@ -860,8 +859,7 @@ class [[nodiscard]] APInt { /// relative logical shift right APInt relativeLShr(int RelativeShift) const { - int Shift = std::abs(RelativeShift); - return RelativeShift > 0 ? lshr(Shift) : shl(Shift); + return RelativeShift > 0 ? lshr(RelativeShift) : shl(-RelativeShift); } /// relative logical shift left @@ -871,8 +869,7 @@ class [[nodiscard]] APInt { /// relative arithmetic shift right APInt relativeAShr(int RelativeShift) const { - int Shift = std::abs(RelativeShift); - return RelativeShift > 0 ? ashr(Shift) : shl(Shift); + return RelativeShift > 0 ? ashr(RelativeShift) : shl(-RelativeShift); } /// relative arithmetic shift left