On Wed, 3 Jul 2024, Jakub Jelinek wrote: > On Wed, Jul 03, 2024 at 02:24:19PM +0200, Jakub Jelinek wrote: > > > >From 40023cac83562a1451aba550533d042fec1c144e Mon Sep 17 00:00:00 2001 > > > From: Richard Biener <rguent...@suse.de> > > > Date: Tue, 11 Jun 2024 13:11:08 +0200 > > > Subject: [PATCH] middle-end/115426 - wrong gimplification of "rm" asm > > > output > > > operand > > > To: gcc-patches@gcc.gnu.org > > > > > > When the operand is gimplified to an extract of a register or a > > > register we have to disallow memory as we otherwise fail to > > > gimplify it properly. Instead of > > > > > > __asm__("" : "=rm" __imag <r>); > > > > > > we want > > > > > > __asm__("" : "=rm" D.2772); > > > _1 = REALPART_EXPR <r>; > > > r = COMPLEX_EXPR <_1, D.2772>; > > > > > > otherwise SSA rewrite will fail and generate wrong code with 'r' > > > left bare in the asm output. > > > > > > PR middle-end/115426 > > > * gimplify.cc (gimplify_asm_expr): Handle "rm" output > > > constraint gimplified to a register (operation). > > > > > > * gcc.dg/pr115426.c: New testcase. > > > > LGTM, thanks. > > Actually, wonder if that assert won't trigger on something invalid like > "=i" (__imag__ r) > which previously got rejected only during expansion.
This case works - the path only triggers when allows_mem so I think it should be safe. > So maybe instead of the assert just do your new handling just for allows_reg > && allows_mem and leave the rest as before. But "=mi" would be a valid constraint (even if a literal immediate would be never OK there)? But yeah, && allows_reg would make it obviously safe. I'll adjust and re-fire the testing. Richard. > Jakub > > -- Richard Biener <rguent...@suse.de> SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)