public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix endianness assumption in LRA
@ 2015-09-15  7:10 David Miller
  2015-09-16 15:59 ` Vladimir Makarov
  0 siblings, 1 reply; 2+ messages in thread
From: David Miller @ 2015-09-15  7:10 UTC (permalink / raw)
  To: gcc-patches; +Cc: vmakarov


This was the most glaring case, and would result in LRA crashing
if this code snippet was actually hit on big-endian, since
simplify_gen_subreg() will return NULL in such a case and then
we try to blindly emit a move to 'subreg'.

There is code in match_reload which seems to have a similar problem,
specifically these sequences:

	  if (SCALAR_INT_MODE_P (inmode))
	    new_out_reg = gen_lowpart_SUBREG (outmode, reg);
	  else
	    new_out_reg = gen_rtx_SUBREG (outmode, reg, 0);
 ...
	  if (SCALAR_INT_MODE_P (outmode))
	    new_in_reg = gen_lowpart_SUBREG (inmode, reg);
	  else
	    new_in_reg = gen_rtx_SUBREG (inmode, reg, 0);

But I have not tried to address those cases in this patch.

Vlad, is this OK to commit?

2015-09-14  David S. Miller  <davem@davemloft.net>

	* lra-constraints.c (simplify_operand_subreg): Do not assume that
	lowpart of a SUBREG has offset zero.

diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c
index cdb2695..fc8e43d 100644
--- a/gcc/lra-constraints.c
+++ b/gcc/lra-constraints.c
@@ -1545,7 +1545,7 @@ simplify_operand_subreg (int nop, machine_mode reg_mode)
 	  bool insert_before, insert_after;
 
 	  PUT_MODE (new_reg, mode);
-          subreg = simplify_gen_subreg (innermode, new_reg, mode, 0);
+          subreg = gen_lowpart_SUBREG (innermode, new_reg);
 	  bitmap_set_bit (&lra_subreg_reload_pseudos, REGNO (new_reg));
 
 	  insert_before = (type != OP_OUT);

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix endianness assumption in LRA
  2015-09-15  7:10 [PATCH] Fix endianness assumption in LRA David Miller
@ 2015-09-16 15:59 ` Vladimir Makarov
  0 siblings, 0 replies; 2+ messages in thread
From: Vladimir Makarov @ 2015-09-16 15:59 UTC (permalink / raw)
  To: David Miller, gcc-patches

On 09/15/2015 02:39 AM, David Miller wrote:
> This was the most glaring case, and would result in LRA crashing
> if this code snippet was actually hit on big-endian, since
> simplify_gen_subreg() will return NULL in such a case and then
> we try to blindly emit a move to 'subreg'.
>
>
> Vlad, is this OK to commit?
Yes. Thanks, David.

We could use subreg_lowpart_offset for simplify_gen_subreg but for this 
case it would be just wasting computer cycles.
> 2015-09-14  David S. Miller  <davem@davemloft.net>
>
> 	* lra-constraints.c (simplify_operand_subreg): Do not assume that
> 	lowpart of a SUBREG has offset zero.
>
> diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c
> index cdb2695..fc8e43d 100644
> --- a/gcc/lra-constraints.c
> +++ b/gcc/lra-constraints.c
> @@ -1545,7 +1545,7 @@ simplify_operand_subreg (int nop, machine_mode reg_mode)
>   	  bool insert_before, insert_after;
>   
>   	  PUT_MODE (new_reg, mode);
> -          subreg = simplify_gen_subreg (innermode, new_reg, mode, 0);
> +          subreg = gen_lowpart_SUBREG (innermode, new_reg);
>   	  bitmap_set_bit (&lra_subreg_reload_pseudos, REGNO (new_reg));
>   
>   	  insert_before = (type != OP_OUT);

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-09-16 15:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-15  7:10 [PATCH] Fix endianness assumption in LRA David Miller
2015-09-16 15:59 ` Vladimir Makarov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).