OSDN Git Service

* fold-const.c (fold): Convert (or (not arg0) (not arg1))
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 15 Oct 1999 05:46:35 +0000 (05:46 +0000)
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 15 Oct 1999 05:46:35 +0000 (05:46 +0000)
        to (not (and (arg0) (arg1))). Similary for and.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@30001 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/fold-const.c

index 1052217..cda319d 100644 (file)
@@ -9,6 +9,9 @@ Thu Oct 14 22:14:23 1999  Richard Henderson  <rth@cygnus.com>
 
 Thu Oct 14 19:44:08 1999  Jan Hubicka  <hubicka@freesoft.cz>
 
+       * fold-const.c (fold): Convert (or (not arg0) (not arg1))
+       to (not (and (arg0) (arg1))). Similary for and.
+
        * fold-const.c (fold): Move bit_rotate code to the EXPR_PLUS case,
        falltrought to assocate code.
        Convert XOR to OR in code like (a&c1)^(a&c2) where c1 and c2 don't have
index 5ea6129..f055d23 100644 (file)
@@ -5183,6 +5183,21 @@ fold (expr)
       if (t1 != NULL_TREE)
        return t1;
 
+      /* Convert (or (not arg0) (not arg1)) to (not (and (arg0) (arg1))).
+
+        This results in more efficient code for machines without a NAND 
+        instruction.  Combine will canonicalize to the first form
+        which will allow use of NAND instructions provided by the
+        backend if they exist.  */
+      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;
@@ -5241,6 +5256,22 @@ fold (expr)
                  & (((HOST_WIDE_INT) 1 << prec) - 1)) == 0)
            return build1 (NOP_EXPR, type, TREE_OPERAND (arg0, 0));
        }
+
+      /* Convert (or (not arg0) (not arg1)) to (not (and (arg0) (arg1))).
+
+        This results in more efficient code for machines without a NOR 
+        instruction.  Combine will canonicalize to the first form
+        which will allow use of NOR instructions provided by the
+        backend if they exist.  */
+      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: