Tiny combine tweek

Jan Hubicka jh@suse.cz
Wed Jun 4 08:06:00 GMT 2003


Hi,
Michael noticed that combine sometimes confuses itself by creating such
a noop if_then_else construct out of nontrivial noop expressions having
register operand with only two possible values.

Regtested/bootstrapped mainline, OK?
Honza

Tue Jun  3 16:51:06 CEST 2003
	* combine.c (simplify_if_then_else): (IF_THEN_ELSE (NE REG 0) (0) (8))
	is REG for nonzero_bits (REG) == 8.  
Index: combine.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/combine.c,v
retrieving revision 1.323.2.14
diff -c -3 -p -r1.323.2.14 combine.c
*** combine.c	28 Mar 2003 11:42:50 -0000	1.323.2.14
--- combine.c	3 Jun 2003 14:51:02 -0000
*************** simplify_if_then_else (x)
*** 5113,5118 ****
--- 5113,5126 ----
        simplify_shift_const (NULL_RTX, ASHIFT, mode,
  			    gen_lowpart_for_combine (mode, XEXP (cond, 0)), i);
  
+   /* (IF_THEN_ELSE (NE REG 0) (0) (8)) is REG for nonzero_bits (REG) == 8.  */
+   if (true_code == NE && XEXP (cond, 1) == const0_rtx
+       && false_rtx == const0_rtx && GET_CODE (true_rtx) == CONST_INT
+       && (INTVAL (true_rtx) & GET_MODE_MASK (mode))
+ 	  == nonzero_bits (XEXP (cond, 0), mode)
+       && (i = exact_log2 (INTVAL (true_rtx) & GET_MODE_MASK (mode))) >= 0)
+     return XEXP (cond, 0);
+ 
    return x;
  }
  



More information about the Gcc-patches mailing list