================ @@ -2030,32 +2031,68 @@ Value *llvm::addDiffRuntimeChecks( // Map to keep track of created compares, The key is the pair of operands for // the compare, to allow detecting and re-using redundant compares. DenseMap<std::pair<Value *, Value *>, Value *> SeenCompares; - for (const auto &[SrcStart, SinkStart, AccessSize, NeedsFreeze] : Checks) { + Value *AliasLaneMask = nullptr; + for (const auto &[SrcStart, SinkStart, AccessSize, NeedsFreeze, + WriteAfterRead] : Checks) { Type *Ty = SinkStart->getType(); - // Compute VF * IC * AccessSize. - auto *VFTimesICTimesSize = - ChkBuilder.CreateMul(GetVF(ChkBuilder, Ty->getScalarSizeInBits()), - ConstantInt::get(Ty, IC * AccessSize)); - Value *Diff = - Expander.expandCodeFor(SE.getMinusSCEV(SinkStart, SrcStart), Ty, Loc); - - // Check if the same compare has already been created earlier. In that case, - // there is no need to check it again. - Value *IsConflict = SeenCompares.lookup({Diff, VFTimesICTimesSize}); - if (IsConflict) - continue; + if (!VF.isScalar() && UseSafeEltsMask) { ---------------- SamTebbs33 wrote:
I think that `VF.isScalar()` is actually an unnecessary check since the memory check block is only used if the LV actually ends up vectorising or if epilogue vectorisation is on. In the case of epilogue vectorisation it won't use tail predication and tail predication being off turns off `UseSafeEltsMask`. As per Florian's suggestion I've separated this into two functions. https://github.com/llvm/llvm-project/pull/100579 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits