middle-end/115426 - wrong gimplification of "rm" asm output operand
commita4bbdec2be1c9f8fb49276b8a54ee86024ceac17
authorRichard Biener <rguenther@suse.de>
Tue, 11 Jun 2024 11:11:08 +0000 (11 13:11 +0200)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 4 Jul 2024 06:57:54 +0000 (4 08:57 +0200)
treea46284182cbd1ebdf472bf7d575b1df268e444dd
parent699087a16591adfdf21228876b6c48dbcd353faa
middle-end/115426 - wrong gimplification of "rm" asm output operand

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.
gcc/gimplify.cc
gcc/testsuite/gcc.dg/pr115426.c [new file with mode: 0644]