[llvm] [PeepholeOptimizer] Recognize new move-immediate instructions (PR #72128)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 14 08:33:41 PST 2023


jayfoad wrote:

> > Perhaps other targets never create sequences where a move-immediate feeds into another move? Perhaps AMDGPU should not create them either?
> 
> For the most part, we shouldn't. I think in general this is the class of problem that RegBankSelect or follow up optimizations should be avoiding before selection. It might make sense to preserve this pattern in rare situations with multiple uses of the constant

\<AMDGPU-specific\>

OK, makes sense, but then we end up with things like this:

v_mov_b32 v1, 0x12345678
v_mov_b32 v2, 0x23456789
v_fma_f32 v0, v0, v1, v2 // v0 = v0 * v1 + v2

On GFX10+, the best thing SIFoldOperands could do with this is to fold one of the constants in as a literal, and the other one as an sgpr:

s_mov_b32 s2, 0x23456789
v_fma_f32 v0, v0, 0x12345678, s2

But currently it has no way to "go backwards" from a constant in a vgpr to the same constant in an sgpr.

\</AMDGPU-specific\>

https://github.com/llvm/llvm-project/pull/72128


More information about the llvm-commits mailing list