diff mbox

Make more use of subreg_offset_from_lsb

Message ID 8760dev9qy.fsf@linaro.org
State Accepted
Commit dc0c1e44766b850cf7418badc99a97a044681409
Headers show

Commit Message

Richard Sandiford Aug. 23, 2017, 10:50 a.m. UTC
This patch makes use of the subreg_offset_from_lsb function
added by an earlier patch in the SVE series.

Tested on aarch64-linux-gnu and x86_64-linux-gnu, and by making sure
that there were no differences in testsuite assembly output for one
target per CPU.  OK to install?

Richard


2017-08-23  Richard Sandiford  <richard.sandiford@linaro.org>
	    Alan Hayward  <alan.hayward@arm.com>
	    David Sherwood  <david.sherwood@arm.com>

gcc/
	* combine.c (make_extraction): Use subreg_offset_from_lsb.

Comments

Segher Boessenkool Aug. 23, 2017, 4 p.m. UTC | #1
On Wed, Aug 23, 2017 at 11:50:13AM +0100, Richard Sandiford wrote:
> This patch makes use of the subreg_offset_from_lsb function

> added by an earlier patch in the SVE series.

> 

> Tested on aarch64-linux-gnu and x86_64-linux-gnu, and by making sure

> that there were no differences in testsuite assembly output for one

> target per CPU.  OK to install?


Okay, also the other combine parts in this series.  Thanks!


Segher


> 	* combine.c (make_extraction): Use subreg_offset_from_lsb.
diff mbox

Patch

Index: gcc/combine.c
===================================================================
--- gcc/combine.c	2017-08-23 10:44:56.293484623 +0100
+++ gcc/combine.c	2017-08-23 10:45:34.493718192 +0100
@@ -7482,26 +7482,15 @@  make_extraction (machine_mode mode, rtx
 		 return a new hard register.  */
 	      if (pos || in_dest)
 		{
-		  HOST_WIDE_INT final_word = pos / BITS_PER_WORD;
-
-		  if (WORDS_BIG_ENDIAN
-		      && GET_MODE_SIZE (inner_mode) > UNITS_PER_WORD)
-		    final_word = ((GET_MODE_SIZE (inner_mode)
-				   - GET_MODE_SIZE (tmode))
-				  / UNITS_PER_WORD) - final_word;
-
-		  final_word *= UNITS_PER_WORD;
-		  if (BYTES_BIG_ENDIAN &&
-		      GET_MODE_SIZE (inner_mode) > GET_MODE_SIZE (tmode))
-		    final_word += (GET_MODE_SIZE (inner_mode)
-				   - GET_MODE_SIZE (tmode)) % UNITS_PER_WORD;
+		  unsigned int offset
+		    = subreg_offset_from_lsb (tmode, inner_mode, pos);
 
 		  /* Avoid creating invalid subregs, for example when
 		     simplifying (x>>32)&255.  */
-		  if (!validate_subreg (tmode, inner_mode, inner, final_word))
+		  if (!validate_subreg (tmode, inner_mode, inner, offset))
 		    return NULL_RTX;
 
-		  new_rtx = gen_rtx_SUBREG (tmode, inner, final_word);
+		  new_rtx = gen_rtx_SUBREG (tmode, inner, offset);
 		}
 	      else
 		new_rtx = gen_lowpart (tmode, inner);