diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c
index 397744f742b..414d1dda316 100644
--- a/gas/config/tc-xtensa.c
+++ b/gas/config/tc-xtensa.c
@@ -12520,7 +12520,9 @@ void
 istack_push (IStack *stack, TInsn *insn)
 {
   int rec = stack->ninsn;
-  gas_assert (!istack_full (stack));
+  if (istack_full (stack))
+    as_fatal (_("internal error: instruction stack overflow; "
+		"increase MAX_ISTACK"));
   stack->insn[rec] = *insn;
   stack->ninsn++;
 }
@@ -12534,7 +12536,9 @@ istack_push_space (IStack *stack)
 {
   int rec = stack->ninsn;
   TInsn *insn;
-  gas_assert (!istack_full (stack));
+  if (istack_full (stack))
+    as_fatal (_("internal error: instruction stack overflow; "
+		"increase MAX_ISTACK"));
   insn = &stack->insn[rec];
   tinsn_init (insn);
   stack->ninsn++;
diff --git a/gas/config/xtensa-istack.h b/gas/config/xtensa-istack.h
index 15e34c2b9d8..67367f16f12 100644
--- a/gas/config/xtensa-istack.h
+++ b/gas/config/xtensa-istack.h
@@ -23,7 +23,10 @@
 
 #include "xtensa-isa.h"
 
-#define MAX_ISTACK 12
+/* Must hold the largest multi-instruction widening expansion from
+   widen_spec_list in xtensa-relax.c.  Currently that is the loopgtz
+   + L32R sequence (13 entries including LITERAL and LABEL).  */
+#define MAX_ISTACK 16
 #define MAX_INSN_ARGS 64
 
 enum itype_enum
diff --git a/gas/testsuite/gas/xtensa/loopgtz-relax.d b/gas/testsuite/gas/xtensa/loopgtz-relax.d
new file mode 100644
index 00000000000..1374186c6d6
--- /dev/null
+++ b/gas/testsuite/gas/xtensa/loopgtz-relax.d
@@ -0,0 +1,16 @@
+#as:
+#objdump: -d
+
+#...
+.*beqz.*a9,.*
+.*bltz.*a9,.*
+.*loopgtz.*a9,.*
+.*rsr.lend.*a9
+.*wsr.lbeg.*a9
+.*l32r.*a9,.*
+.*nop
+.*wsr.lend.*a9
+.*isync
+.*rsr.lcount.*a9
+.*addi.*a9, a9, 1
+#...
diff --git a/gas/testsuite/gas/xtensa/loopgtz-relax.s b/gas/testsuite/gas/xtensa/loopgtz-relax.s
new file mode 100644
index 00000000000..a03528f306c
--- /dev/null
+++ b/gas/testsuite/gas/xtensa/loopgtz-relax.s
@@ -0,0 +1,10 @@
+	.text
+	.globl main
+	.align 4
+main:
+	loopgtz a9, .Lloop_end
+	.rep 200
+	nop
+	.endr
+.Lloop_end:
+	nop
