[llvm-commits] [llvm] r171000 - /llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp

David Blaikie dblaikie at gmail.com
Thu Dec 27 11:41:32 PST 2012


On Sun, Dec 23, 2012 at 5:19 AM, Benjamin Kramer
<benny.kra at googlemail.com> wrote:
> Author: d0k
> Date: Sun Dec 23 07:19:18 2012
> New Revision: 171000
>
> URL: http://llvm.org/viewvc/llvm-project?rev=171000&view=rev
> Log:
> LoopVectorize: For scalars and void types there is no need to compute vector insert/extract costs.
>
> Fixes an assert during the build of oggenc in the test suite.

Even though this is in the test-suite, it'd be nice to have a narrow
regression test to go along with this change as well so we'll catch
this sooner rather than later.

> Modified:
>     llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp
>
> Modified: llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp?rev=171000&r1=170999&r2=171000&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp (original)
> +++ llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp Sun Dec 23 07:19:18 2012
> @@ -2181,18 +2181,16 @@
>      // elements, times the vector width.
>      unsigned Cost = 0;
>
> -    bool IsVoid = RetTy->isVoidTy();
> -
> -    unsigned InsCost = (IsVoid ? 0 :
> -                        VTTI->getVectorInstrCost(Instruction::InsertElement,
> -                                           VectorTy));
> -
> -    unsigned ExtCost = VTTI->getVectorInstrCost(Instruction::ExtractElement,
> -                                          VectorTy);
> -
> -    // The cost of inserting the results plus extracting each one of the
> -    // operands.
> -    Cost += VF * (InsCost + ExtCost * I->getNumOperands());
> +    if (RetTy->isVoidTy() || VF != 1) {
> +      unsigned InsCost = VTTI->getVectorInstrCost(Instruction::InsertElement,
> +                                                  VectorTy);
> +      unsigned ExtCost = VTTI->getVectorInstrCost(Instruction::ExtractElement,
> +                                                  VectorTy);
> +
> +      // The cost of inserting the results plus extracting each one of the
> +      // operands.
> +      Cost += VF * (InsCost + ExtCost * I->getNumOperands());
> +    }
>
>      // The cost of executing VF copies of the scalar instruction. This opcode
>      // is unknown. Assume that it is the same as 'mul'.
>
>
> _______________________________________________
> 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