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]

middle-end/7561: Prefetch merging code in gcc-3.1/gcc/loop.c incorect


>Number:         7561
>Category:       middle-end
>Synopsis:       Prefetch merging code in gcc-3.1/gcc/loop.c incorect
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Aug 09 11:06:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Rob Redmond, University of Toronto
>Release:        3.1
>Organization:
>Environment:
Intel Pentium3
Redhat Linux 7.2
>Description:
See  emit_prefetch_instruction() in gcc-3.1/gcc/loop.c

After examining a general induction variable (GIV) to determine if it is eligible for prefetching, emit_prefetch_instruction() compares the newly identified "prefetchable" GIV with all the previously identified "prefetchable" GIVs (which share a common basic induction variable (BIV)) to determine if they can be merged.

In the first case were two GIV's can be merged, the address of the new one is greater than that of the existing one, causing the existing prefetch's info to be replaced by info related to the new prefetch.

                if (index >= info[i].index && index - info[i].index < 4096)
                  {
                    info[i].write |= d.mem_write;
                    info[i].bytes_accesed += size;
                    info[i].index = index;
                    info[i].giv = iv;
                    info[i].class = bl;
                    info[num_prefetches].base_address = address;
                    add = 0;
                    break;
                  }

The code above (as it appears in loop.c) does not replace the base address of the existing prefetchable GIV.  Thus, by keeping the address of the lower addressed GIV, the higher addressed GIV will never be prefetched.  In fact, the comments before this code say to, "Just do the later and the earlier will get prefetched from previous iteration.", but this is not being done.

  In addition, since num_prefetches is not incremented when the new prefetch is merged, the assignment of the new prefetch's address to "info[num_prefetches].base_address" is replaced when the next non-mergeable prefetch instruction is identified.
>How-To-Repeat:
This problem is located in the GCC source code.
>Fix:
Change the array index in the line mentioned above from,
"info[num_prefetches].base_address = address" (line #3925) to
"info[i].base_address = address"
>Release-Note:
>Audit-Trail:
>Unformatted:


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