combine.c (simplify_logical): Only simplify logical expressions of the form ior(and...
authorRoger Sayle <roger@eyesopen.com>
Sun, 23 Jan 2005 15:43:56 +0000 (15:43 +0000)
committerRoger Sayle <sayle@gcc.gnu.org>
Sun, 23 Jan 2005 15:43:56 +0000 (15:43 +0000)
* 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.

Co-Authored-By: Eric Botcazou <ebotcazou@libertysurf.fr>
From-SVN: r94114

gcc/ChangeLog
gcc/combine.c

index ce737615e63f1f7660e8234881263a7ec384ffa0..68bc9493ac36854610da03e27082de38901e1f20 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 dca4d971a1e4dbf4567f94ae6d0dce8701d40ee8..0baeb981500e2319af4ab886efc2a47991726451 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