[PATCH] D136675: [MachineCSE] Allow PRE of instructions that read physical registers

John Brawn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 25 04:42:49 PDT 2022


john.brawn created this revision.
john.brawn added reviewers: pzheng, mkitzan, Petar.Avramovic, olista01.
Herald added subscribers: kosarev, kerbowa, hiraditya, kristof.beyls, tpr, jvesely, nemanjai.
Herald added a project: All.
john.brawn requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Currently MachineCSE forbids PRE when the instruction reads a physical register. Relax this so that it's allowed when the value being read is the same as what would be read in the place the instruction would be hoisted to.

This is being done in preparation for adding FPCR handling to the AArch64 backend, in order to prevent it to from worsening the generated code, but for targets that already have a similar register it should improve things.

This patch affects code generation in several tests. The new code looks better except for in Thumb2/LowOverheadLoops/memcall.ll where we perform PRE but the LowOverheadLoops transformation then undoes it. Also in AMDGPU/selectcc-opt.ll the CHECK makes things look worse, but actually the function as a whole is better (as a MOV is PRE'd).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136675

Files:
  llvm/lib/CodeGen/MachineCSE.cpp
  llvm/test/CodeGen/AMDGPU/GlobalISel/hip.extern.shared.array.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/udiv.i64.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/urem.i64.ll
  llvm/test/CodeGen/AMDGPU/selectcc-opt.ll
  llvm/test/CodeGen/PowerPC/machine-cse-rm-pre.mir
  llvm/test/CodeGen/Thumb2/LowOverheadLoops/memcall.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136675.470443.patch
Type: text/x-patch
Size: 33802 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221025/5b084e02/attachment.bin>


More information about the llvm-commits mailing list