[llvm-commits] [llvm] r172348 - in /llvm/trunk: lib/Transforms/Vectorize/LoopVectorize.cpp test/Transforms/LoopVectorize/i8-induction.ll

Duncan Sands baldrick at free.fr
Sun Jan 13 01:39:35 PST 2013


Hi Nadav,

On 13/01/13 08:56, Nadav Rotem wrote:
> Author: nadav
> Date: Sun Jan 13 01:56:29 2013
> New Revision: 172348
>
> URL: http://llvm.org/viewvc/llvm-project?rev=172348&view=rev
> Log:
> Fix PR14547. Handle induction variables of small sizes smaller than i32 (i8 and i16).

> --- llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp (original)
> +++ llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp Sun Jan 13 01:56:29 2013
> @@ -1033,11 +1033,14 @@
>
>     // We may need to extend the index in case there is a type mismatch.
>     // We know that the count starts at zero and does not overflow.
> +  unsigned IdxTyBW = IdxTy->getScalarSizeInBits();
>     if (Count->getType() != IdxTy) {
>       // The exit count can be of pointer type. Convert it to the correct
>       // integer type.
>       if (ExitCount->getType()->isPointerTy())
>         Count = CastInst::CreatePointerCast(Count, IdxTy, "ptrcnt.to.int", Loc);
> +    else if (IdxTyBW < Count->getType()->getScalarSizeInBits())
> +      Count = CastInst::CreateTruncOrBitCast(Count, IdxTy, "tr.cnt", Loc);
>       else
>         Count = CastInst::CreateZExtOrBitCast(Count, IdxTy, "zext.cnt", Loc);
>     }

if you were using an IRBuilder to construct stuff (probably a good idea) then
you could use CreateZExtOrTrunc here instead.

Ciao, Duncan.



More information about the llvm-commits mailing list