[LV] Don't sink scalar instructions that may read from memory.
authorFlorian Hahn <flo@fhahn.com>
Mon, 17 Apr 2023 08:30:25 +0000 (09:30 +0100)
committerFlorian Hahn <flo@fhahn.com>
Mon, 17 Apr 2023 08:30:25 +0000 (09:30 +0100)
commit83ab5708d1d00f4ec2541e960bff3b5c68001c9e
tree3072ae16acdb7e2db7116f8813f03077baadec50
parent721ecc9d413c1043c28924bcec700b4dd46ca2f4
[LV] Don't sink scalar instructions that may read from memory.

The current sinking code doesn't prevent us from sinking a load past an
aliasing store. Skip sinking instructions that may read from memory to
avoid a mis-compile.

See @minimal_bit_widths_with_aliasing_store for an example where 2 loads
are sunk past aliasing stores before this fix.

Reviewed By: Ayal

Differential Revision: https://reviews.llvm.org/D147259
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/test/Transforms/LoopVectorize/if-pred-non-void.ll
llvm/test/Transforms/LoopVectorize/if-pred-stores.ll