[all-commits] [llvm/llvm-project] df0835: [RISCV] Implement foward inserting save/restore FR...

Yeting Kuo via All-commits all-commits at lists.llvm.org
Wed Jan 24 22:42:05 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: df08350dcfc515c5a7c08e1e08047467263cb701
      https://github.com/llvm/llvm-project/commit/df08350dcfc515c5a7c08e1e08047467263cb701
  Author: Yeting Kuo <46629943+yetingk at users.noreply.github.com>
  Date:   2024-01-25 (Thu, 25 Jan 2024)

  Changed paths:
    M llvm/lib/Target/RISCV/RISCVInsertReadWriteCSR.cpp
    A llvm/test/CodeGen/RISCV/rvv/frm-insert.ll

  Log Message:
  -----------
  [RISCV] Implement foward inserting save/restore FRM instructions. (#77744)

Previously, RISCVInsertReadWriteCSR inserted an FRM swap for any value
other than 7 and restored the original value right after the vector
instruction. This is inefficient if multiple vector instructions use the
same rounding mode if the next vector instruction uses a different
explicit rounding mode.

This patch implements a local optimization to solve the above problem.
We assume the starting rounding mode of the basic block is "dynamic."
When iterating through a basic block and encountering an instruction
whose rounding mode is not the same as the current rounding mode, we
change the current rounding mode and save the current rounding mode if
needed. And we may need to restore FRM when encountering function call,
inline asm and some uses of FRM.

The advanced version of this is to perform cross basic block analysis
for the starting rounding mode of each basic block.




More information about the All-commits mailing list