b89248
2018-04-10  Segher Boessenkool  <segher@kernel.crashing.org>
b89248
b89248
        PR target/85287
b89248
        * gcc/config/rs6000/rs6000.md (allocate_stack): Put the residual size
b89248
        for stack clash protection in a register whenever we need it to be in
b89248
        a register.
b89248
b89248
b89248
--- a/gcc/config/rs6000/rs6000.md	2018/04/10 21:09:30	259298
b89248
+++ b/gcc/config/rs6000/rs6000.md	2018/04/10 21:37:34	259299
b89248
@@ -9783,14 +9783,12 @@
b89248
       /* Now handle residuals.  We just have to set operands[1] correctly
b89248
 	 and let the rest of the expander run.  */
b89248
       operands[1] = residual;
b89248
-      if (!CONST_INT_P (residual))
b89248
-	operands[1] = force_reg (Pmode, operands[1]);
b89248
     }
b89248
 
b89248
-  if (GET_CODE (operands[1]) != CONST_INT
b89248
-      || INTVAL (operands[1]) < -32767
b89248
-      || INTVAL (operands[1]) > 32768)
b89248
+  if (!(CONST_INT_P (operands[1])
b89248
+	&& IN_RANGE (INTVAL (operands[1]), -32767, 32768)))
b89248
     {
b89248
+      operands[1] = force_reg (Pmode, operands[1]);
b89248
       neg_op0 = gen_reg_rtx (Pmode);
b89248
       if (TARGET_32BIT)
b89248
 	emit_insn (gen_negsi2 (neg_op0, operands[1]));
b89248
@@ -9798,7 +9796,7 @@
b89248
 	emit_insn (gen_negdi2 (neg_op0, operands[1]));
b89248
     }
b89248
   else
b89248
-    neg_op0 = GEN_INT (- INTVAL (operands[1]));
b89248
+    neg_op0 = GEN_INT (-INTVAL (operands[1]));
b89248
 
b89248
   insn = emit_insn ((* ((TARGET_32BIT) ? gen_movsi_update_stack
b89248
 				       : gen_movdi_di_update_stack))
b89248