[PATCH] D82056: [SVE] Remove calls to VectorType::getNumElements from Transforms/Vectorize

Christopher Tetreault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 25 11:34:06 PDT 2020


ctetreau marked 2 inline comments as done.
ctetreau added inline comments.


================
Comment at: llvm/lib/Transforms/Vectorize/VectorCombine.cpp:339
+  auto *DestTy = dyn_cast<FixedVectorType>(I.getType());
+  auto *SrcTy = cast<FixedVectorType>(V->getType());
   if (!DestTy || I.getOperand(0)->getType() != SrcTy)
----------------
ctetreau wrote:
> spatel wrote:
> > IIUC, we can't safely cast to FixedVectorType at this point (the dyn_cast may have failed).
> > 
> > Should we add a test like this:
> > 
> > ```
> > define <vscale x 4 x float> @scalable_bitcast_same_elt_size(<vscale x 4 x i32> %v) {
> >   %shuf = shufflevector <vscale x 4 x i32> %v, <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer
> >   %r = bitcast <vscale x 4 x i32> %shuf to <vscale x 4 x float>
> >   ret <vscale x 4 x float> %r
> > }
> > 
> > ```
> > 
> > I would add that in a preliminary commit myself, but it already crashes somewhere in the TTI cost model.
> I can take a look at adding this test case and seeing if I can get to this line with a scalable vector.
Looking at this more closely, it occurs to me that the TTI stuff is completely unimplemented for scalable vectors currently, so I'm not going to be able to add this test case. That said, for now, the scope of the cast to FixedVectorType can be reduced to just the two calls to getNumElements(). In principle, it should be possible to implement this function in terms of ElementCount. I'll add a fixme for this.

I think this should be safe, assuming it passes all the tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82056



More information about the llvm-commits mailing list