Patch to fold-const.c to convert (or (not ...) (not ...))

Jan Hubicka hubicka@atrey.karlin.mff.cuni.cz
Thu Oct 14 04:53:00 GMT 1999


Thu Oct 14 13:49:30 MET DST 1999  Jan Hubicka  <hubicka@freesoft.cz>
	* fold-const.c (fold_expr): Convert (or (not arg0) (not arg1))
	to (not (and (arg0) (arg1))). Similary for and.

*** fold-const.old	Thu Oct 14 12:19:10 1999
--- fold-const.c	Thu Oct 14 13:47:26 1999
--- 5167,5188 ----
        if (t1 != NULL_TREE)
  	return t1;
  
!       /* Convert (or (not arg0) (not arg1)) to (not (and (arg0) (arg1))).
! 	 While this is non-canonical, it is one instruction shorter than
! 	 former and combine is able to canonize it and match NAND pattern
! 	 when available.  */
!       if (TREE_CODE (arg0) == BIT_NOT_EXPR
! 	  && TREE_CODE (arg1) == BIT_NOT_EXPR)
  	{
! 	  return fold (build1 (BIT_NOT_EXPR, type,
! 			       build (BIT_AND_EXPR, type,
! 				      TREE_OPERAND (arg0, 0),
! 				      TREE_OPERAND (arg1, 0))));
  	}
  
!       /* See if this can be simplified into a rotate first.  If that
! 	 is unsuccessful continue in the association code.  */
!       goto bit_rotate;
        }
  
      case BIT_XOR_EXPR:
*************** fold (expr) 
*** 5206,5211 ****
--- 5239,5258 ----
  		  & (((HOST_WIDE_INT) 1 << prec) - 1)) == 0)
  	    return build1 (NOP_EXPR, type, TREE_OPERAND (arg0, 0));
  	}
+ 
+       /* Convert (and (not arg0) (not arg1)) to (not (or (arg0) (arg1))).
+ 	 While this is non-canonical, it is one instruction shorter than
+ 	 former and combine is able to canonize it and match NOR pattern
+ 	 when available.  */
+       if (TREE_CODE (arg0) == BIT_NOT_EXPR
+ 	  && TREE_CODE (arg1) == BIT_NOT_EXPR)
+ 	{
+ 	  return fold (build1 (BIT_NOT_EXPR, type,
+ 			       build (BIT_IOR_EXPR, type,
+ 				      TREE_OPERAND (arg0, 0),
+ 				      TREE_OPERAND (arg1, 0))));
+ 	}
+ 
        goto associate;
  
      case BIT_ANDTC_EXPR:


More information about the Gcc-patches mailing list