[PATCH] [x86] Fold extract_vector_elt of a load into the load's address computation.

Michael Spencer bigcheesegs at gmail.com
Tue Apr 15 19:06:18 PDT 2014


On Tue, Apr 15, 2014 at 6:10 PM, Quentin Colombet <qcolombet at apple.com> wrote:
>
>   Hi Michael,
>
>   DAGCombiner has a load slicing mechanism what tries to produce target friendly loads. Maybe we could extend this mechanism to handle this kind of cases.
>   Do not know how easy that would be, but that seems to me like the natural place to start :).
>
>   You can take a look at DAGCombiner::SliceUpLoad.
>
>   Thanks,
>   -Quentin
>
> http://reviews.llvm.org/D3375
>
>

So I was looking through DAGCombiner and noticed that
visitEXTRACT_VECTOR_ELT has a comment which states that it already
does this optimization. But only for constant element indices after
legalization. I'm going to take a look into making this code handle
the non-constant case. The only thing I'm not sure about is how to
tell if this would generate bad code in other cases.

visitEXTRACT_VECTOR_ELT also only does this optimization if there is
only one use of the load. For my case it's better to do this
optimization even if there are other uses of the entire vector load.
But this is only because vbroadcastss requires an address in avx. Non
vbroadcastss uses or avx2 vbroadcastss uses don't have this problem.

- Michael Spencer



More information about the llvm-commits mailing list