Index: config/rs6000/rs6000.c =================================================================== --- config/rs6000/rs6000.c (revision 248140) +++ config/rs6000/rs6000.c (working copy) @@ -28372,7 +28372,21 @@ rs6000_emit_allocate_stack (HOST_WIDE_IN && REGNO (stack_limit_rtx) > 1 && REGNO (stack_limit_rtx) <= 31) { - emit_insn (gen_add3_insn (tmp_reg, stack_limit_rtx, GEN_INT (size))); + rtx cst = GEN_INT (size); + + /* The add expander doesn't correctly handle r0. */ + if (satisfies_constraint_I (cst)) + emit_insn (gen_rtx_SET (tmp_reg, + gen_rtx_PLUS (Pmode, stack_limit_rtx, + cst))); + else + { + emit_move_insn (tmp_reg, cst); + emit_insn (gen_rtx_SET (tmp_reg, + gen_rtx_PLUS (Pmode, stack_limit_rtx, + tmp_reg))); + } + emit_insn (gen_cond_trap (LTU, stack_reg, tmp_reg, const0_rtx)); }