https://gcc.gnu.org/g:2c50499a8a35324f91c5d1ed5def3cf0687b6da0
commit 2c50499a8a35324f91c5d1ed5def3cf0687b6da0 Author: Andrew Stubbs <[email protected]> Date: Wed Nov 11 17:57:47 2026 +0000 amdgcn: add zero_extendsidi and extendsidi These help register allocation by avoiding the partially undefined registers that are used in the default lowering. Now, the values remain 64-bit all the way past reload. We were already doing that for vectors. This gives a noticeable speedup in miniBUDE. gcc/ChangeLog: * config/gcn/gcn.md (zero_extendsidi2): New. (extendsidi2): New. (cherry picked from commit 3f2de41a37cc57d3eedb270a7a1ff2c4449ee733) Diff: --- gcc/config/gcn/gcn.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/gcc/config/gcn/gcn.md b/gcc/config/gcn/gcn.md index 0692cb1fd54a..cd44502d5f5c 100644 --- a/gcc/config/gcn/gcn.md +++ b/gcc/config/gcn/gcn.md @@ -1974,6 +1974,44 @@ (set_attr "simt_clobber" "2") (set_attr "simt_const" "si2")]) +; Without these, the middle end sets the two halves via subregs, which +; leaves the DImode pseudo live (partially undefined) all the way back +; to the function entry. Splitting after reload avoids that. + +(define_insn_and_split "zero_extendsidi2" + [(set (match_operand:DI 0 "register_operand") + (zero_extend:DI (match_operand:SI 1 "register_operand")))] + "" + {@ [cons: =0,1; attrs: type,length] + [Sg,Sg;mult,8] # + [v ,v ;mult,8] # + } + "&& reload_completed" + [(set (match_dup 2) (match_dup 1)) + (set (match_dup 3) (const_int 0))] + { + operands[2] = gcn_operand_part (DImode, operands[0], 0); + operands[3] = gcn_operand_part (DImode, operands[0], 1); + }) + +(define_insn_and_split "extendsidi2" + [(set (match_operand:DI 0 "register_operand") + (sign_extend:DI (match_operand:SI 1 "register_operand"))) + (clobber (match_scratch:BI 2))] + "" + {@ [cons: =0,1,=2; attrs: type,length] + [Sg,Sg,cs;mult,12] # + [v ,v ,X ;mult,12] # + } + "&& reload_completed" + [(set (match_dup 3) (match_dup 1)) + (parallel [(set (match_dup 4) (ashiftrt:SI (match_dup 3) (const_int 31))) + (clobber (match_dup 2))])] + { + operands[3] = gcn_operand_part (DImode, operands[0], 0); + operands[4] = gcn_operand_part (DImode, operands[0], 1); + }) + ;; }}} ;; {{{ ALU: generic 128-bit binop
