OSDN Git Service

* combine.c (simplify_logical): Only simplify logical expressions
authorsayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 23 Jan 2005 15:43:56 +0000 (15:43 +0000)
committersayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 23 Jan 2005 15:43:56 +0000 (15:43 +0000)
of the form ior(and(x,y),z) by the inverse distributive law if the
result is cheaper than the original.

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

gcc/ChangeLog
gcc/combine.c

index ce73761..68bc949 100644 (file)
@@ -1,3 +1,10 @@
+2005-01-23  Roger Sayle  <roger@eyesopen.com>
+           Eric Botcazou  <ebotcazou@libertysurf.fr>
+
+       * combine.c (simplify_logical): Only simplify logical expressions
+       of the form ior(and(x,y),z) by the inverse distributive law if the
+       result is cheaper than the original.
+
 2005-01-23  Kazu Hirata  <kazu@cs.umass.edu>
 
        * alias.c, c-common.h, c-incpath.c, c-incpath.h, expr.c,
index dca4d97..0baeb98 100644 (file)
@@ -5574,26 +5574,28 @@ simplify_logical (rtx x)
 
       if (GET_CODE (op0) == AND)
        {
-         x = apply_distributive_law
+         rtx tmp = apply_distributive_law
            (gen_binary (AND, mode,
                         gen_binary (IOR, mode, XEXP (op0, 0), op1),
                         gen_binary (IOR, mode, XEXP (op0, 1),
                                     copy_rtx (op1))));
 
-         if (GET_CODE (x) != IOR)
-           return x;
+         if (GET_CODE (tmp) != IOR
+             && rtx_cost (tmp, SET) < rtx_cost (x, SET))
+           return tmp;
        }
 
       if (GET_CODE (op1) == AND)
        {
-         x = apply_distributive_law
+         rtx tmp = apply_distributive_law
            (gen_binary (AND, mode,
                         gen_binary (IOR, mode, XEXP (op1, 0), op0),
                         gen_binary (IOR, mode, XEXP (op1, 1),
                                     copy_rtx (op0))));
 
-         if (GET_CODE (x) != IOR)
-           return x;
+         if (GET_CODE (tmp) != IOR
+             && rtx_cost (tmp, SET) < rtx_cost (x, SET))
+           return tmp;
        }
 
       /* Convert (ior (ashift A CX) (lshiftrt A CY)) where CX+CY equals the