Patchwork [wide-int] Postreload LOAD_EXTEND_OP handling

login
register
mail settings
Submitter Richard Sandiford
Date Nov. 9, 2013, 10:58 a.m.
Message ID <878uwxg7tc.fsf@talisman.default>
Download mbox | patch
Permalink /patch/289969/
State New
Headers show

Comments

Richard Sandiford - Nov. 9, 2013, 10:58 a.m.
LOAD_EXTEND_OP is about extending a subword value to a word.  The final
wide_int should therefore be word_mode rather than GET_MODE (src).

Tested on powerpc64-linux-gnu and by rerunning the assembly comparison.
OK to install?

Thanks,
Richard
Kenneth Zadeck - Nov. 9, 2013, 3:18 p.m.
On 11/09/2013 05:58 AM, Richard Sandiford wrote:
> LOAD_EXTEND_OP is about extending a subword value to a word.  The final
> wide_int should therefore be word_mode rather than GET_MODE (src).
>
> Tested on powerpc64-linux-gnu and by rerunning the assembly comparison.
> OK to install?
>
> Thanks,
> Richard
>
>
> Index: gcc/postreload.c
> ===================================================================
> --- gcc/postreload.c	2013-11-09 09:39:16.947734730 +0000
> +++ gcc/postreload.c	2013-11-09 09:39:29.721821066 +0000
> @@ -303,21 +303,19 @@ reload_cse_simplify_set (rtx set, rtx in
>   	      switch (extend_op)
>   		{
>   		case ZERO_EXTEND:
> -		  result = wide_int (std::make_pair (this_rtx, GET_MODE (src)));
> -		  if (GET_MODE_PRECISION (GET_MODE (src))
> -		      > GET_MODE_PRECISION (word_mode))
> -		    result = wi::zext (result, GET_MODE_PRECISION (word_mode));
> +		  result = wide_int::from (std::make_pair (this_rtx,
> +							   GET_MODE (src)),
> +					   BITS_PER_WORD, UNSIGNED);
>   		  break;
>   		case SIGN_EXTEND:
> -		  result = wide_int (std::make_pair (this_rtx, GET_MODE (src)));
> -		  if (GET_MODE_PRECISION (GET_MODE (src))
> -		      > GET_MODE_PRECISION (word_mode))
> -		    result = wi::sext (result, GET_MODE_PRECISION (word_mode));
> +		  result = wide_int::from (std::make_pair (this_rtx,
> +							   GET_MODE (src)),
> +					   BITS_PER_WORD, SIGNED);
>   		  break;
>   		default:
>   		  gcc_unreachable ();
>   		}
> -	      this_rtx = immed_wide_int_const (result, GET_MODE (src));
> +	      this_rtx = immed_wide_int_const (result, word_mode);
>   	    }
>   #endif
>   	  this_cost = set_src_cost (this_rtx, speed);
This is really your domain.  i cannot comment on this.

Patch

Index: gcc/postreload.c
===================================================================
--- gcc/postreload.c	2013-11-09 09:39:16.947734730 +0000
+++ gcc/postreload.c	2013-11-09 09:39:29.721821066 +0000
@@ -303,21 +303,19 @@  reload_cse_simplify_set (rtx set, rtx in
 	      switch (extend_op)
 		{
 		case ZERO_EXTEND:
-		  result = wide_int (std::make_pair (this_rtx, GET_MODE (src)));
-		  if (GET_MODE_PRECISION (GET_MODE (src))
-		      > GET_MODE_PRECISION (word_mode))
-		    result = wi::zext (result, GET_MODE_PRECISION (word_mode));
+		  result = wide_int::from (std::make_pair (this_rtx,
+							   GET_MODE (src)),
+					   BITS_PER_WORD, UNSIGNED);
 		  break;
 		case SIGN_EXTEND:
-		  result = wide_int (std::make_pair (this_rtx, GET_MODE (src)));
-		  if (GET_MODE_PRECISION (GET_MODE (src))
-		      > GET_MODE_PRECISION (word_mode))
-		    result = wi::sext (result, GET_MODE_PRECISION (word_mode));
+		  result = wide_int::from (std::make_pair (this_rtx,
+							   GET_MODE (src)),
+					   BITS_PER_WORD, SIGNED);
 		  break;
 		default:
 		  gcc_unreachable ();
 		}
-	      this_rtx = immed_wide_int_const (result, GET_MODE (src));
+	      this_rtx = immed_wide_int_const (result, word_mode);
 	    }
 #endif
 	  this_cost = set_src_cost (this_rtx, speed);