public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/27313]  New: Does not emit conditional moves for stores
@ 2006-04-25 15:46 dwarak dot rajagopal at amd dot com
  2006-04-25 17:38 ` [Bug middle-end/27313] " pinskia at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: dwarak dot rajagopal at amd dot com @ 2006-04-25 15:46 UTC (permalink / raw)
  To: gcc-bugs

int cmov(int* A ,int B ,int C ,int* D ,int* E ,int F ,int g) {
  int k,f;
  for (k = 1; k <= 1000; k++) {
    A[k] = B+C;
    g = D[k-1] + E[k-1];
    if (g > A[k])  A[k]=g;      /* This is not converted to cmov*/
    f += g;
  }
  return f;
}

In the above code, the if-then statement is not converted to conditional move.
It fails for "noce_mem_write_may_trap_or_fault_p ()" condition in "ifcvt.c" as
it thinks that there is a chance for A[k] access to trap.
The fact here is that in this case, A[k] will never trap because the A[k] is
already been written once along the path from Entry to the "A[k] = g". So it is
safe to convert it to a cmov statement. Though there might be two extra moves
(mem to reg and vice versa) statement, it is still better to avoid the branch
especially if it is unpredictable data like for the eg above.

There is a typical case like this in Spec 2006 456.hmmer benchmark. Using
contional moves will make the code faster by 13%-17%. 

-Dwarak


-- 
           Summary: Does not emit conditional moves for stores
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dwarak dot rajagopal at amd dot com
 GCC build triplet: x86_64
  GCC host triplet: x86_64
GCC target triplet: x86_64


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


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

end of thread, other threads:[~2009-05-09 13:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-25 15:46 [Bug c/27313] New: Does not emit conditional moves for stores dwarak dot rajagopal at amd dot com
2006-04-25 17:38 ` [Bug middle-end/27313] " pinskia at gcc dot gnu dot org
2006-04-25 18:38 ` pinskia at gcc dot gnu dot org
2006-04-25 19:07 ` dwarak dot rajagopal at amd dot com
2006-09-21 13:07 ` rguenth at gcc dot gnu dot org
2006-11-11 16:47 ` steven at gcc dot gnu dot org
2009-05-09  1:21 ` wilson at gcc dot gnu dot org
2009-05-09 13:00 ` rguenth at gcc dot gnu dot 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).