From: Jan Hubicka Date: Fri, 15 Oct 1999 05:46:35 +0000 (+0200) Subject: fold-const.c (fold): Convert (or (not arg0) (not arg1)) to (not (and (arg0) (arg1))). X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ccc5fd95b241d216fb93ff30384593c3b2df846e;p=gcc.git fold-const.c (fold): Convert (or (not arg0) (not arg1)) to (not (and (arg0) (arg1))). * fold-const.c (fold): Convert (or (not arg0) (not arg1)) to (not (and (arg0) (arg1))). Similary for and. From-SVN: r30001 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1052217e579..cda319df398 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -9,6 +9,9 @@ Thu Oct 14 22:14:23 1999 Richard Henderson Thu Oct 14 19:44:08 1999 Jan Hubicka + * 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 diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 5ea6129de80..f055d23a13d 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -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: