[llvm-commits] [llvm] r78821 - /llvm/trunk/lib/Support/APInt.cpp

Chris Lattner clattner at apple.com
Wed Aug 12 10:54:44 PDT 2009


On Aug 12, 2009, at 10:42 AM, Dale Johannesen wrote:

> Author: johannes
> Date: Wed Aug 12 12:42:34 2009
> New Revision: 78821
>
> URL: http://llvm.org/viewvc/llvm-project?rev=78821&view=rev
> Log:
> Fix a nondeterministic bug in APInt::roundToDouble;
> when !isSingleWord() but getActiveBits() is small,
> we were using the pointer value instead of the low
> word of the integer value.

Great catch Dale, can you please add a comment to that function that  
indicates why it uses getWord(0) instead of VAL?  I could see someone  
"optimizing" this back in the future.

-Chris


>
>
>
> Modified:
>    llvm/trunk/lib/Support/APInt.cpp
>
> Modified: llvm/trunk/lib/Support/APInt.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APInt.cpp?rev=78821&r1=78820&r2=78821&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- llvm/trunk/lib/Support/APInt.cpp (original)
> +++ llvm/trunk/lib/Support/APInt.cpp Wed Aug 12 12:42:34 2009
> @@ -897,10 +897,10 @@
>   // Handle the simple case where the value is contained in one  
> uint64_t.
>   if (isSingleWord() || getActiveBits() <= APINT_BITS_PER_WORD) {
>     if (isSigned) {
> -      int64_t sext = (int64_t(VAL) << (64-BitWidth)) >> (64- 
> BitWidth);
> +      int64_t sext = (int64_t(getWord(0)) << (64-BitWidth)) >> (64- 
> BitWidth);
>       return double(sext);
>     } else
> -      return double(VAL);
> +      return double(getWord(0));
>   }
>
>   // Determine if the value is negative.
>
>
> _______________________________________________
> 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