diff mbox series

[rs6000] fix ICE for strncmp expansion on power6

Message ID c2b491dc-8bff-c419-c0ab-68a86e876865@linux.ibm.com
State New
Headers show
Series [rs6000] fix ICE for strncmp expansion on power6 | expand

Commit Message

Aaron Sawdey Nov. 2, 2018, 2:58 p.m. UTC
This patch addresses an ICE for a missing instruction when targeting power6. The issue
is that we shouldn't generate x-form load rtx if TARGET_AVOID_XFORM is true because
it won't end up being matched. More generally, on big endian we do not need to use
ldbrx et. al. which are index loads, but can just use ld and other normal d-form
loads. So this is going to generate better code for BE in general which is why I have
changed it to do this for big endian or TARGET_AVOID_XFORM.

Bootstrap/regtest passes on ppc32 and ppc64 (power 6/7/8), ok for trunk?

Thanks!
   Aaron


2018-11-02  Aaron Sawdey  <acsawdey@linux.ibm.com>

	* config/rs6000/rs6000-string.c (expand_strncmp_gpr_sequence): Pay
	attention to TARGET_AVOID_XFORM.

Comments

Segher Boessenkool Nov. 2, 2018, 4:47 p.m. UTC | #1
On Fri, Nov 02, 2018 at 09:58:50AM -0500, Aaron Sawdey wrote:
> This patch addresses an ICE for a missing instruction when targeting power6. The issue
> is that we shouldn't generate x-form load rtx if TARGET_AVOID_XFORM is true because
> it won't end up being matched. More generally, on big endian we do not need to use
> ldbrx et. al. which are index loads, but can just use ld and other normal d-form
> loads. So this is going to generate better code for BE in general which is why I have
> changed it to do this for big endian or TARGET_AVOID_XFORM.

Great :-)

> 2018-11-02  Aaron Sawdey  <acsawdey@linux.ibm.com>
> 
> 	* config/rs6000/rs6000-string.c (expand_strncmp_gpr_sequence): Pay
> 	attention to TARGET_AVOID_XFORM.

Also mention BIG_ENDIAN please?

Okay with that.  Thanks!


Segher
diff mbox series

Patch

Index: gcc/config/rs6000/rs6000-string.c
===================================================================
--- gcc/config/rs6000/rs6000-string.c	(revision 265733)
+++ gcc/config/rs6000/rs6000-string.c	(working copy)
@@ -1798,12 +1798,18 @@ 
 	   rid of the extra bytes.  */
 	cmp_bytes = bytes_to_compare;

-      rtx offset_reg = gen_reg_rtx (Pmode);
-      emit_move_insn (offset_reg, GEN_INT (offset));
-
-      rtx addr1 = gen_rtx_PLUS (Pmode, src1_addr, offset_reg);
+      rtx offset_rtx;
+      if (BYTES_BIG_ENDIAN || TARGET_AVOID_XFORM)
+	offset_rtx = GEN_INT (offset);
+      else
+	{
+	  offset_rtx = gen_reg_rtx (Pmode);
+	  emit_move_insn (offset_rtx, GEN_INT (offset));
+	}
+      rtx addr1 = gen_rtx_PLUS (Pmode, src1_addr, offset_rtx);
+      rtx addr2 = gen_rtx_PLUS (Pmode, src2_addr, offset_rtx);
+	
       do_load_for_compare_from_addr (load_mode, tmp_reg_src1, addr1, orig_src1);
-      rtx addr2 = gen_rtx_PLUS (Pmode, src2_addr, offset_reg);
       do_load_for_compare_from_addr (load_mode, tmp_reg_src2, addr2, orig_src2);

       /* We must always left-align the data we read, and