diff options
| author | Zvi Rackover <zvi.rackover@intel.com> | 2017-05-08 12:40:18 +0000 |
|---|---|---|
| committer | Zvi Rackover <zvi.rackover@intel.com> | 2017-05-08 12:40:18 +0000 |
| commit | dfbd3d79039a3709ad90953b4dfc418d417067ec (patch) | |
| tree | e56147b4e2a44297bf371137d1673e643dda5f52 /llvm/include | |
| parent | b6d8070205906513bef1de87f096ff737ae621a3 (diff) | |
| download | bcm5719-llvm-dfbd3d79039a3709ad90953b4dfc418d417067ec.tar.gz bcm5719-llvm-dfbd3d79039a3709ad90953b4dfc418d417067ec.zip | |
IR: Add a shufflevector mask commutation helper function. NFC.
Summary:
Following up on Sanjay's suggetion in D32955, move this functionality
into ShuffleVectornstruction.
Reviewers: spatel, RKSimon
Reviewed By: RKSimon
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D32956
llvm-svn: 302420
Diffstat (limited to 'llvm/include')
| -rw-r--r-- | llvm/include/llvm/IR/Instructions.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/include/llvm/IR/Instructions.h b/llvm/include/llvm/IR/Instructions.h index 844a7273eca..1b75b2cd7ba 100644 --- a/llvm/include/llvm/IR/Instructions.h +++ b/llvm/include/llvm/IR/Instructions.h @@ -2261,6 +2261,19 @@ public: return Mask; } + /// Change values in a shuffle permute mask assuming the two vector operands + /// of length InVecNumElts have swapped position. + static void commuteShuffleMask(MutableArrayRef<int> Mask, + unsigned InVecNumElts) { + for (int &Idx : Mask) { + if (Idx == -1) + continue; + Idx = Idx < (int)InVecNumElts ? Idx + InVecNumElts : Idx - InVecNumElts; + assert(Idx >= 0 && Idx < (int)InVecNumElts * 2 && + "shufflevector mask index out of range"); + } + } + // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const Instruction *I) { return I->getOpcode() == Instruction::ShuffleVector; |

