In the process, use the existing masked.load combine which is slightly stronger, and handles a mix of zero and undef elements in the mask.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358913
91177308-0d34-0410-b5e6-
96231b3b80d8
// Handle intrinsics with 3 or more arguments.
switch (IID) {
- case Intrinsic::masked_load: {
+ case Intrinsic::masked_load:
+ case Intrinsic::masked_gather: {
Value *MaskArg = ArgBegin[2];
Value *PassthruArg = ArgBegin[3];
// If the mask is all zeros or undef, the "passthru" argument is the result.
// * Vector splat address w/known mask -> scalar load
// * Vector incrementing address -> vector masked load
static Instruction *simplifyMaskedGather(IntrinsicInst &II, InstCombiner &IC) {
- // If the mask is all zeros, return the "passthru" argument of the gather.
- auto *ConstMask = dyn_cast<Constant>(II.getArgOperand(2));
- if (ConstMask && ConstMask->isNullValue())
- return IC.replaceInstUsesWith(II, II.getArgOperand(3));
-
return nullptr;
}