This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: optimization/5244: Dead code in simplify_logical()


In PR 5244:
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5244

you submitted a patch, which I have reproduced here

in unified context diff format.  Can you explain

why this patch is necessary?  I did not

understand your explanation.

Index: combine.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/combine.c,v
retrieving revision 1.183.2.8
diff -u -r1.183.2.8 combine.c
--- combine.c   2001/11/05 19:10:32     1.183.2.8
+++ combine.c   2002/01/29 03:58:03
@@ -5391,8 +5391,25 @@
         If we have (and (ior A B) C), apply the distributive law and then
         the inverse distributive law to see if things simplify.  */

+      /* Similarly, taking advantage of the fact that
+        (and (not A) (xor B C)) == (xor (ior A B) (ior A C))  */
+
+      if (GET_CODE (op0) == NOT && GET_CODE (op1) == XOR)
+       return apply_distributive_law
+         (gen_binary (XOR, mode,
+                      gen_binary (IOR, mode, XEXP (op0, 0), XEXP (op1, 0)),
+                      gen_binary (IOR, mode, copy_rtx (XEXP (op0, 0)),
+                                  XEXP (op1, 1))));
+
+      else if (GET_CODE (op1) == NOT && GET_CODE (op0) == XOR)
+       return apply_distributive_law
+         (gen_binary (XOR, mode,
+                      gen_binary (IOR, mode, XEXP (op1, 0), XEXP (op0, 0)),
+                      gen_binary (IOR, mode, copy_rtx (XEXP (op1, 0)), XEXP (op0, 1))));
+
       if (GET_CODE (op0) == IOR || GET_CODE (op0) == XOR)
        {
+         /* ??? May we get better code, if we do this optimization anyway  */
          x = apply_distributive_law
            (gen_binary (GET_CODE (op0), mode,
                         gen_binary (AND, mode, XEXP (op0, 0), op1),
@@ -5409,21 +5426,6 @@
                       gen_binary (AND, mode, XEXP (op1, 1),
                                   copy_rtx (op0))));

-      /* Similarly, taking advantage of the fact that
-        (and (not A) (xor B C)) == (xor (ior A B) (ior A C))  */
-
-      if (GET_CODE (op0) == NOT && GET_CODE (op1) == XOR)
-       return apply_distributive_law
-         (gen_binary (XOR, mode,
-                      gen_binary (IOR, mode, XEXP (op0, 0), XEXP (op1, 0)),
-                      gen_binary (IOR, mode, copy_rtx (XEXP (op0, 0)),
-                                  XEXP (op1, 1))));
-
-      else if (GET_CODE (op1) == NOT && GET_CODE (op0) == XOR)
-       return apply_distributive_law
-         (gen_binary (XOR, mode,
-                      gen_binary (IOR, mode, XEXP (op1, 0), XEXP (op0, 0)),
-                      gen_binary (IOR, mode, copy_rtx (XEXP (op1, 0)), XEXP (op0, 1))));
       break;

     case IOR:

--
Craig Rodrigues
http://www.gis.net/~craigr
rodrigc@mediaone.net




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]