[RISCV] Don't merge addi into load/store address if addi has a FrameIndex operand.
authorCraig Topper <craig.topper@sifive.com>
Sat, 30 Apr 2022 01:19:05 +0000 (18:19 -0700)
committerCraig Topper <craig.topper@sifive.com>
Sat, 30 Apr 2022 01:22:20 +0000 (18:22 -0700)
commitf91690f7db96aae16425241a17fe6649f5d156b4
treec441a93dd02cdc7be8a5ede4d6b35dc80cb91a85
parent616dd4fe4ecc6afbdfa0bf13559c49e80da9aa28
[RISCV] Don't merge addi into load/store address if addi has a FrameIndex operand.

This fixes a crash from D124231.

We can't fold
  (load (add base, (addi src, off1)), off2)
     -> (load (add base, src), off1+off2)
if the src is a FrameIndex. FrameIndex cannot be the operand of an
add.

There was an immediate==0 check that I think was trying to catch
the common case of FrameIndex addis where the immediate is 0, but
they can also appear in non-zero form. Instead explicitly check
for a FrameIndex operand.
llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
llvm/test/CodeGen/RISCV/mem.ll