From 0e7f6fb6b418952e558b8b56ebd8655b133919ec Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Wed, 19 Apr 2017 23:55:48 +0000 Subject: [PATCH] [APInt] Don't call getActiveBits() in ult/ugt(uint64_t) if its a single word. The compiled code already needs to check single/multi word for the countLeadingZeros call inside of getActiveBits, but it isn't able to optimize out the leadingZeros call in the single word case that can't produce a value larger than 64. This shrank the opt binary by about 5-6k on my local x86-64 build. llvm-svn: 300798 --- llvm/include/llvm/ADT/APInt.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h index e517a13..1eff4b6 100644 --- a/llvm/include/llvm/ADT/APInt.h +++ b/llvm/include/llvm/ADT/APInt.h @@ -1083,7 +1083,8 @@ public: /// /// \returns true if *this < RHS when considered unsigned. bool ult(uint64_t RHS) const { - return getActiveBits() > 64 ? false : getZExtValue() < RHS; + // Only need to check active bits if not a single word. + return (isSingleWord() || getActiveBits() <= 64) && getZExtValue() < RHS; } /// \brief Signed less than comparison @@ -1151,7 +1152,8 @@ public: /// /// \returns true if *this > RHS when considered unsigned. bool ugt(uint64_t RHS) const { - return getActiveBits() > 64 ? true : getZExtValue() > RHS; + // Only need to check active bits if not a single word. + return (!isSingleWord() && getActiveBits() > 64) || getZExtValue() > RHS; } /// \brief Signed greather than comparison -- 2.7.4