[PATCH] Using Masked Load / Store intrinsics in Loop Vectorizer

Michael Zolotukhin mzolotukhin at apple.com
Tue Dec 9 15:39:43 PST 2014


> On Dec 9, 2014, at 12:01 AM, Elena Demikhovsky <elena.demikhovsky at intel.com> wrote:
> 
> To Michael: 
> Some tests fail in this case, I tried. Because NumberOfStoresToPredicate allows you to predicated some stores without masking.
> I wanted to keep this knob as is.
Actually, I didn’t intend to change the original logic (though accidentally I changed it). 
> I also do not check mayThrow() because it is for calls only.
Are you sure that we also don’t need the next check?
```
    // Check that we don't have a constant expression that can trap as operand.
    for (Instruction::op_iterator OI = it->op_begin(), OE = it->op_end();
         OI != OE; ++OI) {
      if (Constant *C = dyn_cast<Constant>(*OI))
        if (C->canTrap())
          return false;
    }
```

If that check is also unneeded, I’d suggest rewriting the ‘if' in a following way (but I also don’t mind if you decide to keep it as-is):
```
      if (NumPredStores >= NumberOfStoresToPredicate || !isSafePtr ||
          !isSinglePredecessor) {
        // Build a masked store if it is legal for the target, otherwise scalarize
        // the block.
        if (isLegalMaskedStore(SI->getValueOperand()->getType(),
                             SI->getPointerOperand())) {
          MaskedOp.insert(SI);
          continue;
        }
        ++NumPredStores; // I’m not sure if this increment is actually needed here
        return false;
      }
    ++NumPredStores;
```
> 
> To Nadav:
>> Maybe a better name would be "isMaskRequired"?
> No problem
> 
> http://reviews.llvm.org/D6527
> 
> 





More information about the llvm-commits mailing list