Hi,
this patch mitigates the excessive stack usage on arm in code
that does lots of int64 shift ops like sha512.
It reduces the stack usage in that example from 4K to 2K while
less than 0.5K would be expected.
In all cases the additional set instructions are optimized later
so that this caused no code size increase, but just made
LRA's job a bit easier.
It does certainly not solve the problem completely but at least
improve the stability, in an area that I'd call security relevant.
Boot-strapped and reg-tested on arm-linux-gnueabihf.
Is it OK for trunk?
Thanks
Bernd.
2016-09-29 Bernd Edlinger <bernd.edlin...@hotmail.de>
PR target/77308
* config/arm/arm.c (arm_emit_coreregs_64bit_shift): Clear the result
register explicitly.
Index: gcc/config/arm/arm.c
===================================================================
--- gcc/config/arm/arm.c (revision 239624)
+++ gcc/config/arm/arm.c (working copy)
@@ -29159,6 +29159,7 @@ arm_emit_coreregs_64bit_shift (enum rtx_code code,
/* Shifts by a constant less than 32. */
rtx reverse_amount = GEN_INT (32 - INTVAL (amount));
+ emit_insn (SET (out, const0_rtx));
emit_insn (SET (out_down, LSHIFT (code, in_down, amount)));
emit_insn (SET (out_down,
ORR (REV_LSHIFT (code, in_up, reverse_amount),
@@ -29170,12 +29171,11 @@ arm_emit_coreregs_64bit_shift (enum rtx_code code,
/* Shifts by a constant greater than 31. */
rtx adj_amount = GEN_INT (INTVAL (amount) - 32);
+ emit_insn (SET (out, const0_rtx));
emit_insn (SET (out_down, SHIFT (code, in_up, adj_amount)));
if (code == ASHIFTRT)
emit_insn (gen_ashrsi3 (out_up, in_up,
GEN_INT (31)));
- else
- emit_insn (SET (out_up, const0_rtx));
}
}
else