Hi! The inline-asm here has "1p" constraint and we end up with (plus (frame) (const_int ...)) as input; even when the matching output is a REG, I'm not really sure emit_move_insn can handle arbitrary expressions (consider e.g. "1X" constraint), and calling reg_overlap_mentioned_p on something other than REG/SUBREG/MEM/constant (and a couple of selected other cases) will ICE too. My understanding is that the match_asm_constraints mini-pass is an optimization, so we can try to handle cases which make sense, but if there is something too difficult to handle we can just punt and let reload do its job or error_for_asm if it can't reload it. Especially when I believe such input expressions can be there only when the numeric constraint is mixed with some other one, otherwise it should have been a REG or MEM or something similar.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2018-03-19 Jakub Jelinek <ja...@redhat.com> PR inline-asm/84941 * function.c (match_asm_constraints_1): Don't do the optimization if input isn't a REG, SUBREG, MEM or constant. * gcc.dg/pr84941.c: New test. --- gcc/function.c.jj 2018-02-22 12:37:02.621387697 +0100 +++ gcc/function.c 2018-03-19 11:51:51.429738406 +0100 @@ -6662,7 +6662,9 @@ match_asm_constraints_1 (rtx_insn *insn, if (! REG_P (output) || rtx_equal_p (output, input) || (GET_MODE (input) != VOIDmode - && GET_MODE (input) != GET_MODE (output))) + && GET_MODE (input) != GET_MODE (output)) + || !(REG_P (input) || SUBREG_P (input) + || MEM_P (input) || CONSTANT_P (input))) continue; /* We can't do anything if the output is also used as input, --- gcc/testsuite/gcc.dg/pr84941.c.jj 2018-03-19 11:56:34.086713406 +0100 +++ gcc/testsuite/gcc.dg/pr84941.c 2018-03-19 11:55:47.301717544 +0100 @@ -0,0 +1,10 @@ +/* PR inline-asm/84941 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +void +foo (void) +{ + short *b[1] = { 0 }; + asm volatile ("" : "=m" (b), "=r" (b) : "1p" (b)); +} Jakub