[PATCH] D129948: [RISCV] Fold stack reload into sext.w by using lw instead of ld.

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 18 09:38:02 PDT 2022


reames added inline comments.


================
Comment at: llvm/test/CodeGen/RISCV/stack-folding.ll:24
+; CHECK-NEXT:    sd s11, 24(sp) # 8-byte Folded Spill
+; CHECK-NEXT:    sd a1, 8(sp) # 8-byte Folded Spill
+; CHECK-NEXT:    sd a0, 16(sp) # 8-byte Folded Spill
----------------
Hm, looking at these spills sparks a question for discussion.

Do we have infrastructure to narrow the spill itself?  If we know only four bytes are used, can we use a narrower store?  And maybe even a smaller stack slot?  I think the answer is here is no, but maybe it's worth some discussion?

There's two ways of narrowing this I see.  

The first is the use of the narrow type - though that's been lowered so I really mean the presence of the sext.w.  This could be phrased as some time of demanded bits analysis.  Though, given how late we spill, maybe we don't have anything like that.  

The second is exploiting the fact that only the i1 comparison value is actually needed.  We could hoist the compare up to the site of the spill, and then store only the i1 - probably i8 in practice - result to the stack.  This has all the general speculation safety and profitability concerns.  

Anyways, just a thought that occurred.  


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129948/new/

https://reviews.llvm.org/D129948



More information about the llvm-commits mailing list