[PATCH] D74495: [VectorCombine] try to form vector binop to eliminate an extract element

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 13 08:06:27 PST 2020


spatel marked 3 inline comments as done.
spatel added inline comments.


================
Comment at: llvm/lib/Transforms/Vectorize/VectorCombine.cpp:103
+  // TODO: Relax the one-use constraints by adjusting the cost calc.
+  if (Ext0 != Ext1 && (!Ext0->hasOneUse() || !Ext1->hasOneUse()))
+    return false;
----------------
lebedev.ri wrote:
> lebedev.ri wrote:
> > But even if it's the same extract, do we not care whether it will go away or not,
> > unlike the case with two different extracts?
> > I.e. for now i'd expect
> > ```
> >   if (!(Ext0 == Ext1 && Ext0->hasNUses(2)) &&
> >       !(Ext0->hasOneUse() && Ext1->hasOneUse()))
> >     return false;
> > ```
> (it might be better to handle extract cost from the getgo?)
Yes, identical operands creates a loophole that might allow vectorization where it wasn't intended, so we should include it in this patch rather than making a follow-on. 

I've added a pile of tests that hopefully check all of the possibilities now. I don't see any x86 combos where the vector op is cheaper than the sibling scalar op, so those will all be negative tests.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74495/new/

https://reviews.llvm.org/D74495





More information about the llvm-commits mailing list