[llvm] r177608 - Use pre-inc, pre-dec when possible.

Jakub Staszak kubastaszak at gmail.com
Wed Mar 20 17:06:55 PDT 2013


Forgot to mention. This change refers to AP(S)Int classes.

- Kuba

On Mar 21, 2013, at 12:56 AM, Jakub Staszak <kubastaszak at gmail.com> wrote:

> Author: kuba
> Date: Wed Mar 20 18:56:19 2013
> New Revision: 177608
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=177608&view=rev
> Log:
> Use pre-inc, pre-dec when possible.
> They are generally faster (at least not slower) than post-inc, post-dec.
> 
> Modified:
>    llvm/trunk/include/llvm/ADT/APSInt.h
>    llvm/trunk/lib/IR/Instructions.cpp
>    llvm/trunk/lib/Support/APInt.cpp
> 
> Modified: llvm/trunk/include/llvm/ADT/APSInt.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/APSInt.h?rev=177608&r1=177607&r2=177608&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/ADT/APSInt.h (original)
> +++ llvm/trunk/include/llvm/ADT/APSInt.h Wed Mar 20 18:56:19 2013
> @@ -161,11 +161,11 @@ public:
>   }
> 
>   APSInt& operator++() {
> -    static_cast<APInt&>(*this)++;
> +    ++(static_cast<APInt&>(*this));
>     return *this;
>   }
>   APSInt& operator--() {
> -    static_cast<APInt&>(*this)--;
> +    --(static_cast<APInt&>(*this));
>     return *this;
>   }
>   APSInt operator++(int) {
> 
> Modified: llvm/trunk/lib/IR/Instructions.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Instructions.cpp?rev=177608&r1=177607&r2=177608&view=diff
> ==============================================================================
> --- llvm/trunk/lib/IR/Instructions.cpp (original)
> +++ llvm/trunk/lib/IR/Instructions.cpp Wed Mar 20 18:56:19 2013
> @@ -3000,8 +3000,8 @@ ICmpInst::makeConstantRange(Predicate pr
>   uint32_t BitWidth = C.getBitWidth();
>   switch (pred) {
>   default: llvm_unreachable("Invalid ICmp opcode to ConstantRange ctor!");
> -  case ICmpInst::ICMP_EQ: Upper++; break;
> -  case ICmpInst::ICMP_NE: Lower++; break;
> +  case ICmpInst::ICMP_EQ: ++Upper; break;
> +  case ICmpInst::ICMP_NE: ++Lower; break;
>   case ICmpInst::ICMP_ULT:
>     Lower = APInt::getMinValue(BitWidth);
>     // Check for an empty-set condition.
> @@ -3015,25 +3015,25 @@ ICmpInst::makeConstantRange(Predicate pr
>       return ConstantRange(BitWidth, /*isFullSet=*/false);
>     break;
>   case ICmpInst::ICMP_UGT: 
> -    Lower++; Upper = APInt::getMinValue(BitWidth);        // Min = Next(Max)
> +    ++Lower; Upper = APInt::getMinValue(BitWidth);        // Min = Next(Max)
>     // Check for an empty-set condition.
>     if (Lower == Upper)
>       return ConstantRange(BitWidth, /*isFullSet=*/false);
>     break;
>   case ICmpInst::ICMP_SGT:
> -    Lower++; Upper = APInt::getSignedMinValue(BitWidth);  // Min = Next(Max)
> +    ++Lower; Upper = APInt::getSignedMinValue(BitWidth);  // Min = Next(Max)
>     // Check for an empty-set condition.
>     if (Lower == Upper)
>       return ConstantRange(BitWidth, /*isFullSet=*/false);
>     break;
>   case ICmpInst::ICMP_ULE: 
> -    Lower = APInt::getMinValue(BitWidth); Upper++; 
> +    Lower = APInt::getMinValue(BitWidth); ++Upper; 
>     // Check for a full-set condition.
>     if (Lower == Upper)
>       return ConstantRange(BitWidth, /*isFullSet=*/true);
>     break;
>   case ICmpInst::ICMP_SLE: 
> -    Lower = APInt::getSignedMinValue(BitWidth); Upper++; 
> +    Lower = APInt::getSignedMinValue(BitWidth); ++Upper; 
>     // Check for a full-set condition.
>     if (Lower == Upper)
>       return ConstantRange(BitWidth, /*isFullSet=*/true);
> 
> Modified: llvm/trunk/lib/Support/APInt.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APInt.cpp?rev=177608&r1=177607&r2=177608&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Support/APInt.cpp (original)
> +++ llvm/trunk/lib/Support/APInt.cpp Wed Mar 20 18:56:19 2013
> @@ -559,12 +559,12 @@ bool APInt::slt(const APInt& RHS) const
>   if (lhsNeg) {
>     // Sign bit is set so perform two's complement to make it positive
>     lhs.flipAllBits();
> -    lhs++;
> +    ++lhs;
>   }
>   if (rhsNeg) {
>     // Sign bit is set so perform two's complement to make it positive
>     rhs.flipAllBits();
> -    rhs++;
> +    ++rhs;
>   }
> 
>   // Now we have unsigned values to compare so do the comparison if necessary
> @@ -2116,7 +2116,7 @@ void APInt::fromString(unsigned numbits,
>   }
>   // If its negative, put it in two's complement form
>   if (isNeg) {
> -    (*this)--;
> +    --(*this);
>     this->flipAllBits();
>   }
> }
> @@ -2197,7 +2197,7 @@ void APInt::toString(SmallVectorImpl<cha
>     // Flip the bits and add one to turn it into the equivalent positive
>     // value and put a '-' in the result.
>     Tmp.flipAllBits();
> -    Tmp++;
> +    ++Tmp;
>     Str.push_back('-');
>   }
> 
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits





More information about the llvm-commits mailing list