diff mbox series

[rs6000] PR target/86222 fix truncation issue with constants when compiling -m32

Message ID c5ce72f69998942a6ab51b297ada2eb83bd4a77f.camel@linux.ibm.com
State New
Headers show
Series [rs6000] PR target/86222 fix truncation issue with constants when compiling -m32 | expand

Commit Message

Aaron Sawdey June 21, 2018, 8:32 p.m. UTC
expand_strn_compare was not using gen_int_mode or trunc_int_for_mode to
properly truncate to Pmode when creating contants in the generate rtx.
This lead to an improper constant and the ICE in PR/86222.

Testing on ppc64 with -m32, -m32 -mpowerpc64 and -m64. If regstrap
passes, ok for trunk and backport to 8?

Thanks, 
   Aaron


2018-06-19  Aaron Sawdey  <acsawdey@linux.ibm.com>

	* config/rs6000/rs6000-string.c (expand_strn_compare): Handle -m32
	correctly.

Comments

Segher Boessenkool June 21, 2018, 8:43 p.m. UTC | #1
Hi!

On Thu, Jun 21, 2018 at 03:32:25PM -0500, Aaron Sawdey wrote:
> expand_strn_compare was not using gen_int_mode or trunc_int_for_mode to
> properly truncate to Pmode when creating contants in the generate rtx.
> This lead to an improper constant and the ICE in PR/86222.
> 
> Testing on ppc64 with -m32, -m32 -mpowerpc64 and -m64. If regstrap
> passes, ok for trunk and backport to 8?

Okay for trunk and also for 8.  Nit:

> +	  rtx len_rtx = gen_reg_rtx (Pmode);
> +	  emit_move_insn (len_rtx, gen_int_mode (bytes-compare_length, Pmode));

Spaces around the - please.

Thanks,


Segher
diff mbox series

Patch

Index: gcc/config/rs6000/rs6000-string.c
===================================================================
--- gcc/config/rs6000/rs6000-string.c	(revision 261850)
+++ gcc/config/rs6000/rs6000-string.c	(working copy)
@@ -1925,20 +1925,15 @@ 
 	  /* -m32 -mpowerpc64 results in word_mode being DImode even
 	     though otherwise it is 32-bit. The length arg to strncmp
 	     is a size_t which will be the same size as pointers.  */
-	  rtx len_rtx;
-	  if (TARGET_64BIT)
-	    len_rtx = gen_reg_rtx (DImode);
-	  else
-	    len_rtx = gen_reg_rtx (SImode);
+	  rtx len_rtx = gen_reg_rtx (Pmode);
+	  emit_move_insn (len_rtx, gen_int_mode (bytes, Pmode));
 
-	  emit_move_insn (len_rtx, bytes_rtx);
-
 	  tree fun = builtin_decl_explicit (BUILT_IN_STRNCMP);
 	  emit_library_call_value (XEXP (DECL_RTL (fun), 0),
 				   target, LCT_NORMAL, GET_MODE (target),
 				   force_reg (Pmode, src1_addr), Pmode,
 				   force_reg (Pmode, src2_addr), Pmode,
-				   len_rtx, GET_MODE (len_rtx));
+				   len_rtx, Pmode);
 	}
 
       rtx fin_ref = gen_rtx_LABEL_REF (VOIDmode, final_label);
@@ -2126,18 +2121,12 @@ 
 	}
       else
 	{
-	  rtx len_rtx;
-	  if (TARGET_64BIT)
-	    len_rtx = gen_reg_rtx (DImode);
-	  else
-	    len_rtx = gen_reg_rtx (SImode);
-
-	  emit_move_insn (len_rtx, GEN_INT (bytes - compare_length));
+	  rtx len_rtx = gen_reg_rtx (Pmode);
+	  emit_move_insn (len_rtx, gen_int_mode (bytes-compare_length, Pmode));
 	  tree fun = builtin_decl_explicit (BUILT_IN_STRNCMP);
 	  emit_library_call_value (XEXP (DECL_RTL (fun), 0),
 				   target, LCT_NORMAL, GET_MODE (target),
-				   src1, Pmode, src2, Pmode,
-				   len_rtx, GET_MODE (len_rtx));
+				   src1, Pmode, src2, Pmode, len_rtx, Pmode);
 	}
 
       rtx fin_ref = gen_rtx_LABEL_REF (VOIDmode, final_label);