[PATCH] [X86, AVX] instcombine common cases of vperm2* intrinsics into shuffles

Andrea Di Biagio Andrea_DiBiagio at sn.scee.net
Fri Mar 20 13:01:01 PDT 2015


================
Comment at: lib/Transforms/InstCombine/InstCombineCalls.cpp:203
@@ +202,3 @@
+/// then ignore that half of the mask and clear that half of the vector.
+Instruction *InstCombiner::SimplifyX86vperm2(IntrinsicInst &II) {
+  VectorType *VecTy = cast<VectorType>(II.getType());
----------------
spatel wrote:
> spatel wrote:
> > andreadb wrote:
> > > Why not have a static function instead? If you use a function, you can avoid to to change 'InstCombineInternal.h'.
> > No reason other than cut and paste from the code around this. If this is static, we'd have to pass in a reference to the InstCombiner in order to use ReplaceInstUsesWith(), right? Do you think that's cleaner?
> I think the use of 'Builder' would also require the InstCombiner reference.
I was thinking about something like this:

```
if (Value *V = SimplifyX86vperm2(*II, Builder))
 return ReplaceInstUsesWith(II, V);
```

Basically, the call to 'ReplaceInstUsesWith' could be done by the caller rather than by function 'SimplifyX86vperm2'. Your function can then take as second argument a pointer to the IRBuilder.
So, something like:
```
 static Value *simplifyX86Vperm2f128(IntrinsicInst &II, InstCombiner::BuilderTy *Builder) {...}
```

That said, this was just an idea. I don't know if this is a better/cleaner way for doing it.. but at least (I thought) we avoid to change the header file. :-)

http://reviews.llvm.org/D8486

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list