Index: config/rs6000/rs6000.c =================================================================== --- config/rs6000/rs6000.c (revision 137784) +++ config/rs6000/rs6000.c (working copy) @@ -12288,9 +12288,13 @@ print_operand (FILE *file, rtx x, int co fprintf (file, "0,%s", reg_names[REGNO (tmp)]); else { - gcc_assert (GET_CODE (tmp) == PLUS - && REG_P (XEXP (tmp, 0)) - && REG_P (XEXP (tmp, 1))); + if (!GET_CODE (tmp) == PLUS + || !REG_P (XEXP (tmp, 0)) + || !REG_P (XEXP (tmp, 1))) + { + output_operand_lossage ("invalid %%y value, try using the 'Z' constraint"); + break; + } if (REGNO (XEXP (tmp, 0)) == 0) fprintf (file, "%s,%s", reg_names[ REGNO (XEXP (tmp, 1)) ], Index: testsuite/gcc.target/powerpc/asm-y.c =================================================================== --- testsuite/gcc.target/powerpc/asm-y.c (revision 0) +++ testsuite/gcc.target/powerpc/asm-y.c (revision 0) @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O1" } */ + +/* Test that %yN does not cause an internal error if used incorrectly. */ + +int f(int *a) +{ + asm ("#%y0" : "=m"(a[2])); /* { dg-error "try using the 'Z' constraint" } */ + asm ("#%y0" : "=m"(a[1])); /* { dg-error "try using the 'Z' constraint" } */ + asm ("#%y0" : "=m"(a[0])); +}