[Loads] Check type size in bits during store to load forwarding
authorNikita Popov <npopov@redhat.com>
Fri, 8 Apr 2022 15:26:29 +0000 (17:26 +0200)
committerNikita Popov <npopov@redhat.com>
Fri, 8 Apr 2022 15:29:29 +0000 (17:29 +0200)
commit930a68765dff96927d706d258ef0c2ad9c7ec2ab
tree2c43903fa980fc2559db6535dfd40f2aa444f840
parent29fe998eaa38d52d0f764800e17917cff1375598
[Loads] Check type size in bits during store to load forwarding

Rather than checking the rounded type store size, check the type
size in bits. We don't want to forward a store of i1 to a load
of i8 for example, even though they have the same type store size.
The padding bits have unspecified contents.

This is a partial fix for the issue reported at
https://reviews.llvm.org/D115924#inline-1179482,
the problem also needs to be addressed more generally in the
constant folding code.
llvm/lib/Analysis/Loads.cpp
llvm/test/Transforms/InstCombine/load-store-forward.ll