aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorJan Hubicka <hubicka@freesoft.cz>1999-10-15 07:46:35 +0200
committerJeff Law <law@gcc.gnu.org>1999-10-14 23:46:35 -0600
commitccc5fd95b241d216fb93ff30384593c3b2df846e (patch)
tree9de0a736cbc85624d4b101760b56c60be85135f5 /gcc/fold-const.c
parentf959ff1a09bb1ef2580f6ab1862cf1248a0639cd (diff)
downloadgcc-ccc5fd95b241d216fb93ff30384593c3b2df846e.zip
gcc-ccc5fd95b241d216fb93ff30384593c3b2df846e.tar.gz
gcc-ccc5fd95b241d216fb93ff30384593c3b2df846e.tar.bz2
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
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 5ea6129..f055d23 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: