[PATCH] D32293: InstructionSimplify: Simplify a shuffle with a undef mask to undef

Zvi Rackover via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 20 22:25:25 PDT 2017


zvi added inline comments.


================
Comment at: test/Transforms/InstSimplify/shufflevector.ll:113-119
 define <4 x i32> @undef_mask(<4 x i32> %x) {
 ; CHECK-LABEL: @undef_mask(
 ; CHECK-NEXT:    ret <4 x i32> undef
 ;
   %shuf = shufflevector <4 x i32> %x, <4 x i32> undef, <4 x i32> undef
   ret <4 x i32> %shuf
 }
----------------
davide wrote:
> zvi wrote:
> > davide wrote:
> > > zvi wrote:
> > > > zvi wrote:
> > > > > davide wrote:
> > > > > > We have a similar case here, maybe it makes sense to handle them together?
> > > > > Sorry i don't follow you. What do you mean by handling them together?
> > > > > This case you are pointing out is handled by a more generic combine starting from DAGCombine.cpp:4154
> > > > I actually meant InstructionSimplify.cpp:4154  :)
> > > I was wondering how hard it would be to extend that combine to handle also this case.
> > I plan in a future patch to do a refactoring/NFC-ish canonicalization of the shuffle input vectors and the mask. I believe that will make the special handling of the "single constant vector" case unnecessary, because the unreferenced  variable vector will be canonicalized to an undef. Similarly, it is possible that canonicalization will cover the case of an undef mask, because it will replace both vector operands to undefs and then trivial constant-folding will handle that case.
> > 
> I'd appreciate if you can propose a refactoring before committing this patch (if possible)
D32338 adds a couple of canonicalization rules which are sufficient for what we cover so far.


Repository:
  rL LLVM

https://reviews.llvm.org/D32293





More information about the llvm-commits mailing list