[llvm] [LoopLoadElim] Fix miscompile caused by incorrect store-to-load forwarding across mixed-width clobbers (PR #224833)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 20 03:13:36 PDT 2026


nikic wrote:

> > This change looks very complicated for the issue it fixes. Why is it not good enough to add the load to LoadsWithUnknownDependence?
> 
> I chose candidate-specific handling to avoid blocking valid forwarding when the mixed-width store is overwritten by the forwarding source. The `overwritten_clobber` test case in mixed-width-clobber.ll covers this case.

Is there reason to believe that this is a common case? I'd expect mixed-size accesses on the same pointer to be somewhat rare and not worth the complexity. At least we should check the impact of the simplest solution on llvm-opt-benchmark.

Also, that's not really specific to mixed size accesses, we could have any kind of unknown dependence store followed by a known dependence store -- right? I haven't checked, but I assume that current implementation doesn't bother handling that either?

https://github.com/llvm/llvm-project/pull/224833


More information about the llvm-commits mailing list