public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/61009] New: Incorrect jump threading in dom
@ 2014-04-29 21:33 tejohnson at google dot com
  2014-04-29 21:34 ` [Bug tree-optimization/61009] " tejohnson at google dot com
                   ` (17 more replies)
  0 siblings, 18 replies; 19+ messages in thread
From: tejohnson at google dot com @ 2014-04-29 21:33 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61009

            Bug ID: 61009
           Summary: Incorrect jump threading in dom
           Product: gcc
           Version: 4.10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tejohnson at google dot com

Created attachment 32709
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32709&action=edit
t.C

We ran into a runtime failure that was tracked down to the jump threading
performed during the dom1 pass. I reproduced it with trunk (updated to
r209902).

I've attached a reduced test case. Build with:

g++ -fno-tree-vrp -O2 -std=c++11 -fno-strict-aliasing t.C -S

Unfortunately it isn't runnable, but the problem is apparent in the resulting
dumps/assembly.

The code initially looks like:

   for (int j = 0; j < NKF ; ++j) {
     int field_idx = idxs[j];
     int cmp = doCmp(row_offset, field_idx);
     fprintf (stderr, "cmp=%d\n",cmp);

     if (cmp == 0) {
       continue;
     }
     if (cmp > 0) {
       is_different = true;
       break;
     } else {
       fprintf (stderr, "Incorrect\n");
       return false;
     }
   }

But after dom1 jump threading it looks something like:

   for (int j = 0; j < NKF ; ++j) {
     int field_idx = idxs[j];
     int cmp = doCmp(row_offset, field_idx);
     fprintf (stderr, "cmp=%d\n",cmp);

     if (cmp == 0) {
       goto L1
     }
     if (cmp > 0) {
       is_different = true;
       break;
     } else {
ERROR:
       fprintf (stderr, "Incorrect\n");
       return false;
     }

L1:
     ++j;
     if (j >= NKF)
        break;

     field_idx = idxs[j];
     cmp = doCmp(row_offset, field_idx);
     fprintf (stderr, "cmp=%d\n",cmp);

     if (cmp == 0) {
       goto L1
     }
     goto ERROR
   }

Notice that after threading, the duplicated code wrongly simplifies away the
check of "cmp > 0".

I've also attached the dom1 dump. The problematic jump thread is this one:

  Registering jump thread: (14, 12) incoming edge;  (12, 4) joiner;  (4, 5)
nocopy;

Since some of these blocks (12 and 14) were created by the earlier dom
optimizations, I modified tree-ssa-threadupdate.c to dump the cfg when entering
thread_through_all_blocks. The attached dump includes that extra dump.


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2014-06-12 18:39 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-29 21:33 [Bug tree-optimization/61009] New: Incorrect jump threading in dom tejohnson at google dot com
2014-04-29 21:34 ` [Bug tree-optimization/61009] " tejohnson at google dot com
2014-04-29 21:35 ` pinskia at gcc dot gnu.org
2014-04-29 21:36 ` ppluzhnikov at google dot com
2014-04-29 21:46 ` ppluzhnikov at google dot com
2014-04-29 21:49 ` law at redhat dot com
2014-04-29 22:46 ` tejohnson at google dot com
2014-04-30 18:01 ` law at redhat dot com
2014-04-30 18:57 ` law at redhat dot com
2014-05-07 17:35 ` xinliangli at gmail dot com
2014-05-08 19:46 ` xinliangli at gmail dot com
2014-05-09  4:54 ` law at gcc dot gnu.org
2014-05-09 17:02 ` [Bug tree-optimization/61009] [4.9 Regression] " tejohnson at google dot com
2014-05-09 17:09 ` ppluzhnikov at google dot com
2014-05-09 17:22 ` law at redhat dot com
2014-05-13 20:27 ` law at gcc dot gnu.org
2014-05-13 20:29 ` law at redhat dot com
2014-06-12 17:13 ` law at gcc dot gnu.org
2014-06-12 18:39 ` law at gcc dot gnu.org

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).