Patchwork [combine] Bit-field insertion optimization #2

login
register
mail settings
Submitter Chung-Lin Tang
Date Dec. 10, 2010, 1:16 p.m.
Message ID <4D02283A.4080704@alumni.nthu.edu.tw>
Download mbox | patch
Permalink /patch/75085/
State New
Headers show

Comments

Chung-Lin Tang - Dec. 10, 2010, 1:16 p.m.
On 2010/12/10 07:12, Andrew Pinski wrote:
> On Thu, Dec 9, 2010 at 9:21 AM, Chung-Lin Tang<cltang@codesourcery.com>  wrote:
>> Hi, asides from Andrew's patch, we also have this alternate patch using
>> combine. With respect to the bitfield case here, the two patches are mostly
>> similar in effect, but we thought we'd post both for discussion anyways.
>
> This patch will not bootstrap anywhere because of the warning:
> /data/src/gcc-cavium/clean/trunk/src/gcc/combine.c: In function
> ‘combinable_i3pat’:
> /data/src/gcc-cavium/clean/trunk/src/gcc/combine.c:1941: warning:
> initialization discards qualifiers from pointer target type
>
> +	      rtx exppat = expand_field_assignment (x);
>
> expand_field_assignment returns a const_rtx.
>
> -- Pinski

Sorry I overlooked this. I only built an ARM cross toolchain to test.

Here's a slightly updated patch adding CONST_CAST_RTX(). I didn't find a 
better way to re-organize the related const_rtx/rtx declares; this 
should be the least intrusive fix.

Bootstrapped and tested on i686 without regressions.

Thanks,
Chung-Lin

Patch

Index: gcc/combine.c
===================================================================
--- gcc/combine.c	(revision 167647)
+++ gcc/combine.c	(working copy)
@@ -2030,7 +2030,22 @@ 
 					GET_MODE (inner_dest))))
 	  || (i1_not_in_src && reg_overlap_mentioned_p (i1dest, src))
 	  || (i0_not_in_src && reg_overlap_mentioned_p (i0dest, src)))
-	return 0;
+	{
+	  /* Try again, this time expanding the modifying pattern into
+	     an and/ior/shift expression. */
+	  if (flag_expensive_optimizations)
+	    {
+	      rtx exppat = CONST_CAST_RTX (expand_field_assignment (x));
+	      if (GET_CODE (SET_DEST (exppat)) != GET_CODE (SET_DEST (x)))
+		{
+		  SUBST (*loc, exppat);
+		  return combinable_i3pat (i3, loc, i2dest, i1dest, i0dest,
+					   i1_not_in_src, i0_not_in_src,
+					   pi3dest_killed);
+		}
+	    }
+	  return 0;
+	}
 
       /* If DEST is used in I3, it is being killed in this insn, so
 	 record that for later.  We have to consider paradoxical