During scalar promotion, if there are additional potentially-aliasing loads outside the promoted set, we can still perform a load-only promotion. As the stores are retained, any potentially-aliasing loads will still read the correct value.
This increases the number of load promotions in llvm-test-suite by a factor of two:
| Old | New licm.NumPromotionCandidates | 4448 | 6038 licm.NumLoadPromoted | 479 | 1069 licm.NumLoadStorePromoted | 1459 | 1459
Unfortunately, this does have some impact on compile-time: http://llvm-compile-time-tracker.com/compare.php?from=57f7f0d6cf0706a88e1ecb74f3d3e8891cceabfa&to=72b811738148aab399966a0435f13b695da1c1c8&stat=instructions In part this is because we now have less early bailouts from promotion, but also due to second order effects (e.g. for one case I looked at we spend more time in SLP now).
I think you can early return here if mod is set. The only reason to check for both is if the result mod-noref is useful, and I don't think it is right now.