[llvm-commits] [llvm] r53812 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp
Chris Lattner
clattner at apple.com
Sun Jul 20 20:25:17 PDT 2008
On Jul 20, 2008, at 7:51 PM, Nick Lewycky wrote:
> Author: nicholas
> Date: Sun Jul 20 21:51:31 2008
> New Revision: 53812
>
> URL: http://llvm.org/viewvc/llvm-project?rev=53812&view=rev
> Log:
> Switch on the use of arbitrary precision integers in scalar
> evolution. This will
> bail after 256-bits to avoid producing code that the backends can't
> handle.
> Previously, we capped it at 64-bits, preferring to miscompile in
> those cases.
>
> This change also reverts much of r52248 because the invariants the
> code was
> expecting are now being met.
Uh, legalizetypes is not enabled by default. Please revert this. Did
this pass make check? If so, we need better tests.
-Chris
>
>
> Modified:
> llvm/trunk/lib/Analysis/ScalarEvolution.cpp
>
> Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=53812&r1=53811&r2=53812&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
> +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Sun Jul 20 21:51:31
> 2008
> @@ -538,20 +538,12 @@
>
> assert(K < 9 && "We cannot handle such long AddRecs yet.");
>
> - // FIXME: A temporary hack to remove in future. Arbitrary
> precision integers
> - // aren't supported by the code generator yet. For the dividend,
> the bitwidth
> - // we use is the smallest power of 2 greater or equal to K*W and
> less or equal
> - // to 64. Note that setting the upper bound for bitwidth may
> still lead to
> - // miscompilation in some cases.
> - unsigned DividendBits = 1U << Log2_32_Ceil(K * It->getBitWidth());
> - if (DividendBits > 64)
> - DividendBits = 64;
> -#if 0 // Waiting for the APInt support in the code generator...
> unsigned DividendBits = K * It->getBitWidth();
> -#endif
> + if (DividendBits > 256)
> + return new SCEVCouldNotCompute();
>
> const IntegerType *DividendTy = IntegerType::get(DividendBits);
> - const SCEVHandle ExIt = SE.getTruncateOrZeroExtend(It, DividendTy);
> + const SCEVHandle ExIt = SE.getZeroExtendExpr(It, DividendTy);
>
> // The final number of bits we need to perform the division is the
> maximum of
> // dividend and divisor bitwidths.
> @@ -573,12 +565,7 @@
> Dividend *= N-(K-1);
> if (DividendTy != DivisionTy)
> Dividend = Dividend.zext(DivisionTy->getBitWidth());
> -
> - APInt Result = Dividend.udiv(Divisor);
> - if (Result.getBitWidth() != It->getBitWidth())
> - Result = Result.trunc(It->getBitWidth());
> -
> - return SE.getConstant(Result);
> + return SE.getConstant(Dividend.udiv(Divisor).trunc(It-
> >getBitWidth()));
> }
>
> SCEVHandle Dividend = ExIt;
> @@ -587,11 +574,10 @@
> SE.getMulExpr(Dividend,
> SE.getMinusSCEV(ExIt, SE.getIntegerSCEV(i,
> DividendTy)));
>
> - return SE.getTruncateOrZeroExtend(
> - SE.getUDivExpr(
> - SE.getTruncateOrZeroExtend(Dividend, DivisionTy),
> - SE.getConstant(Divisor)
> - ), It->getType());
> + if (DividendTy != DivisionTy)
> + Dividend = SE.getZeroExtendExpr(Dividend, DivisionTy);
> + return SE.getTruncateExpr(SE.getUDivExpr(Dividend,
> SE.getConstant(Divisor)),
> + It->getType());
> }
>
> /// evaluateAtIteration - Return the value of this chain of
> recurrences at
>
>
> _______________________________________________
> 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