AMDGPU: Optimize s_setreg_b32 to s_denorm_mode/s_round_mode
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Fri, 29 May 2020 00:55:45 +0000 (20:55 -0400)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Sat, 30 May 2020 01:11:36 +0000 (21:11 -0400)
commit0892a96a05a8943457a4a3e2547923087aa06226
tree7481aad7ce4c7c51b9f309d39a58fd5396c724b1
parent4f300d499631504acdd32219254e939697202285
AMDGPU: Optimize s_setreg_b32 to s_denorm_mode/s_round_mode

This is a custom inserter because it was less work than teaching
tablegen a way to indicate that it is sometimes OK to have a no side
effect instruction in the output of a side effecting pattern.

The asm is needed to look like a read of the mode register to prevent
it from being deleted. However, there seems to be a bug where the mode
register def instructions are moved across the asm sideeffect by the
post-RA scheduler.

Another oddity is the immediate is formatted differently between
s_denorm_mode and s_round_mode.
llvm/lib/Target/AMDGPU/SIDefines.h
llvm/lib/Target/AMDGPU/SIISelLowering.cpp
llvm/lib/Target/AMDGPU/SOPInstructions.td
llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.s.setreg.ll
llvm/test/CodeGen/AMDGPU/llvm.amdgcn.s.setreg.ll