Input: void a(float b, double c) { for (int e = 0; e < 2; e++) { asm volatile ("" : "+f" (c)); asm ("" : "+rm" (c = b)); } } Output: $ xgcc -x c++ -S -Wall -fpermissive -O3 - <stdin>: In function 'void a(float, double)': <stdin>:3:34: error: output constraint 0 must specify a single register during RTL pass: stack <stdin>:6:1: internal compiler error: in move_for_stack_reg, at reg-stack.c:1173 0x2d49787 move_for_stack_reg /home/vegard/git/gcc/gcc/reg-stack.c:1173 0x2d5c1fa subst_stack_regs /home/vegard/git/gcc/gcc/reg-stack.c:2437 0x2d5ced7 convert_regs_1 /home/vegard/git/gcc/gcc/reg-stack.c:3062 0x2d5ced7 convert_regs_2 /home/vegard/git/gcc/gcc/reg-stack.c:3197 0x2d64844 convert_regs /home/vegard/git/gcc/gcc/reg-stack.c:3232 0x2d64844 reg_to_stack /home/vegard/git/gcc/gcc/reg-stack.c:3357 0x2d64844 rest_of_handle_stack_regs /home/vegard/git/gcc/gcc/reg-stack.c:3412 0x2d64844 execute /home/vegard/git/gcc/gcc/reg-stack.c:3443 $ xgcc --version xgcc (GCC) 8.0.1 20180301 (experimental) Built from git c435a9e730c6e8f10da09d58b4fc9aaeb401b0d5 (r258097). 4.8.5 seems to produce this: <source>: In function 'void a(float, double)': <source>:3:33: error: output constraint 0 must specify a single register asm volatile ("" : "+f" (c)); ^ <source>:3:33: error: output constraint 0 must specify a single register <source>:3:33: error: implicitly popped regs must be grouped at top of stack Compiler returned: 1 Test case was minimised by C-Reduce.
Started with r204212.
Created attachment 43569 [details] gcc8-pr84683.patch Untested fix.
Author: jakub Date: Tue Mar 6 09:23:36 2018 New Revision: 258273 URL: https://gcc.gnu.org/viewcvs?rev=258273&root=gcc&view=rev Log: PR inline-asm/84683 * reg-stack.c (move_for_stack_reg): If any_malformed_asm, avoid assertion failure. * g++.dg/ext/pr84683.C: New test. Added: trunk/gcc/testsuite/g++.dg/ext/pr84683.C Modified: trunk/gcc/ChangeLog trunk/gcc/reg-stack.c trunk/gcc/testsuite/ChangeLog
Fixed for 8.1+ so far.
GCC 6 branch is being closed
Fixed in GCC 8.
The master branch has been updated by Roger Sayle <sayle@gcc.gnu.org>: https://gcc.gnu.org/g:ff85f0afc7d5684378944f88a9bc9b931034788b commit r13-2653-gff85f0afc7d5684378944f88a9bc9b931034788b Author: Roger Sayle <roger@nextmovesoftware.com> Date: Tue Sep 13 19:49:20 2022 +0100 PR target/106877: Robustify reg-stack to malformed asm. This patch resolves PR target/106877 an ICE-on-invalid inline-asm regression. An innocent upstream change means that the test case from PR inline-asm/84683 now hits a different assert in reg-stack.cc's move_for_stack_reg. Fixed by duplicating Jakub's solution to PR 84683 https://gcc.gnu.org/pipermail/gcc-patches/2018-March/495193.html at this second (similar) gcc_assert. 2022-09-13 Roger Sayle <roger@nextmovesoftware.com> gcc/ChangeLog PR target/106877 * reg-stack.cc (move_for_stack_reg): Check for any_malformed_asm in gcc_assert. gcc/testsuite/ChangeLog PR target/106877 * g++.dg/ext/pr106877.C: New test case.