public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-5529] middle-end: skip checking loop exits if loop malformed [PR111878]
@ 2023-11-16 12:12 Tamar Christina
  0 siblings, 0 replies; only message in thread
From: Tamar Christina @ 2023-11-16 12:12 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:7a496b7ce105185be12e023e749c90d5f7561879

commit r14-5529-g7a496b7ce105185be12e023e749c90d5f7561879
Author: Tamar Christina <tamar.christina@arm.com>
Date:   Thu Nov 16 12:11:22 2023 +0000

    middle-end: skip checking loop exits if loop malformed [PR111878]
    
    Before my refactoring if the loop->latch was incorrect then find_loop_location
    skipped checking the edges and would eventually return a dummy location.
    
    It turns out that a loop can have
    loops_state_satisfies_p (LOOPS_HAVE_RECORDED_EXITS) but also not have a latch
    in which case get_loop_exit_edges traps.
    
    This restores the old behavior.
    
    gcc/ChangeLog:
    
            PR tree-optimization/111878
            * tree-vect-loop-manip.cc (find_loop_location): Skip edges check if
            latch incorrect.
    
    gcc/testsuite/ChangeLog:
    
            PR tree-optimization/111878
            * gcc.dg/graphite/pr111878.c: New test.

Diff:
---
 gcc/testsuite/gcc.dg/graphite/pr111878.c | 19 +++++++++++++++++++
 gcc/tree-vect-loop-manip.cc              |  4 ++++
 2 files changed, 23 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/graphite/pr111878.c b/gcc/testsuite/gcc.dg/graphite/pr111878.c
new file mode 100644
index 00000000000..6722910062e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/graphite/pr111878.c
@@ -0,0 +1,19 @@
+/* { dg-options "-O3 -fgraphite-identity -fsave-optimization-record" } */
+
+int long_c2i_ltmp;
+int *long_c2i_cont;
+
+void
+long_c2i (long utmp, int i)
+{
+  int neg = 1;
+  switch (long_c2i_cont[0])
+    case 0:
+    neg = 0;
+  for (; i; i++)
+    if (neg)
+      utmp |= long_c2i_cont[i] ^ 5;
+    else
+      utmp |= long_c2i_cont[i];
+  long_c2i_ltmp = utmp;
+}
diff --git a/gcc/tree-vect-loop-manip.cc b/gcc/tree-vect-loop-manip.cc
index b9161274ce4..bcd90a331f5 100644
--- a/gcc/tree-vect-loop-manip.cc
+++ b/gcc/tree-vect-loop-manip.cc
@@ -1792,6 +1792,10 @@ find_loop_location (class loop *loop)
   if (!loop)
     return dump_user_location_t ();
 
+  /* For the root of the loop tree return the function location.  */
+  if (!loop_outer (loop))
+    return dump_user_location_t::from_function_decl (cfun->decl);
+
   if (loops_state_satisfies_p (LOOPS_HAVE_RECORDED_EXITS))
     {
       /* We only care about the loop location, so use any exit with location

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-11-16 12:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-16 12:12 [gcc r14-5529] middle-end: skip checking loop exits if loop malformed [PR111878] Tamar Christina

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).