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]

[Bug tree-optimization/78185] Wrong branch optimization with -O1 on x86/x86_64


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78185

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ebotcazou at gcc dot gnu.org

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
diff --git a/gcc/tree-ssa-loop-im.c b/gcc/tree-ssa-loop-im.c
index 463db04..a89cabf 100644
--- a/gcc/tree-ssa-loop-im.c
+++ b/gcc/tree-ssa-loop-im.c
@@ -44,6 +44,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "trans-mem.h"
 #include "gimple-fold.h"
 #include "tree-scalar-evolution.h"
+#include "tree-ssa-loop-niter.h"

 /* TODO:  Support for predicated code motion.  I.e.

@@ -2369,8 +2370,17 @@ fill_always_executed_in_1 (struct loop *loop, sbitmap
contains_call)
            break;

          FOR_EACH_EDGE (e, ei, bb->succs)
-           if (!flow_bb_inside_loop_p (loop, e->dest))
-             break;
+           {
+             /* If there is an exit from this BB.  */
+             if (!flow_bb_inside_loop_p (loop, e->dest))
+               break;
+             /* Or we enter a possibly non-finite loop.
+                ???  Does that reliably detect infinite child loops
+                inside the child loop?  */
+             if (e->dest->loop_father != loop
+                 && ! finite_loop_p (e->dest->loop_father))
+               break;
+           }
          if (e)
            break;


fixes the invariant motion on the GIMPLE level (at quite some cost generally
I would assume, finite_loop_p is quite conservative).  RTL invariant motion
still messes things up then though...  (CCing rtl opt maintainer)

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