[RISCV] Set how many bytes load from or store to stack slot
authorJim Lin <jim@andestech.com>
Fri, 10 Mar 2023 01:03:28 +0000 (09:03 +0800)
committerJim Lin <jim@andestech.com>
Fri, 10 Mar 2023 02:14:59 +0000 (10:14 +0800)
commit7e9293572d332b812eb1e521f0a75a4e7034abbf
tree0122742f6f3e6bef5d16dc9960bd53a643ad2bf1
parent865fb2e44011c60d6d69154d205b55f4b44ff10b
[RISCV] Set how many bytes load from or store to stack slot

Refer from: https://reviews.llvm.org/D44782

After https://reviews.llvm.org/D130302, LW+SEXT.B can be folded into LB
as partially reload stack slot. This gains incorrect optimization result
from `StackSlotColoring` without given the number of bytes exactly load
from stack. LB+SW are mis-interpreted as fully reload/restore from stack
slot without the sign-extension. SW would be considered as a redundant store.

The testcase is copied from llvm/test/CodeGen/X86/pr30821.mir.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D145471
llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
llvm/lib/Target/RISCV/RISCVInstrInfo.h
llvm/test/CodeGen/RISCV/stack-slot-coloring.mir