public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/54935] New: No way to do if converison
@ 2012-10-15 13:26 ysrumyan at gmail dot com
  2012-10-15 13:45 ` [Bug tree-optimization/54935] " ysrumyan at gmail dot com
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: ysrumyan at gmail dot com @ 2012-10-15 13:26 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 54935
           Summary: No way to do if converison
    Classification: Unclassified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: ysrumyan@gmail.com


In a process of analyzing of gcc peformance on x86 including vectorization we
found out that on spec2006/462.libquantum (e.g.file gates.c, routine
quantum_cnot) vectorization of simple loop is not performed since if-conversion
has not happened even if we pass explicit option to if-convert store stmt aka  
"-ftree-loop-if-convert-stores". I can illustrate it on the following simple
test-case:

extern int a[100], b[100];
void foo(int n)
{
  int i;

  for (i=1; i<n;i++) {
    if (a[i] != b[i])
    a[i] = b[i] + 1;
  }
}

Note that if I insert into loop "a[0] = 0;" stmt if conversion will happen but
this is not suitable for the whole benchmark. I also tried to use lto that
could detect writable memory access but without any success. I assume that we
can detect writable accesses without having unconditional write to that memory
but simple through object type specification of a given object. BTW I don't
know how array a[] with external declaration must be defined to put in
read-only section. Please, also check gcc external definition of
"-ftree-loop-if-convert-stores" option that does not match with the following
commentary:

/* Return true when the memory references of STMT won't trap in the
   if-converted code.  There are two things that we have to check for:

   - writes to memory occur to writable memory: if-conversion of
   memory writes transforms the conditional memory writes into
   unconditional writes, i.e. "if (cond) A[i] = foo" is transformed
   into "A[i] = cond ? foo : A[i]", and as the write to memory may not
   be executed at all in the original code, it may be a readonly
   memory.  To check that A is not const-qualified, we check that
   there exists at least an unconditional write to A in the current
   function.

   - reads or writes to memory are valid memory accesses for every
   iteration.  To check that the memory accesses are correctly formed
   and that we are allowed to read and write in these locations, we
   check that the memory accesses to be if-converted occur at every
   iteration unconditionally.  */

static bool
ifcvt_memrefs_wont_trap (gimple stmt, VEC (data_reference_p, heap) *refs)
{
  return write_memrefs_written_at_least_once (stmt, refs)
    && memrefs_read_or_written_unconditionally (stmt, refs);
}


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

end of thread, other threads:[~2021-07-21  3:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-15 13:26 [Bug tree-optimization/54935] New: No way to do if converison ysrumyan at gmail dot com
2012-10-15 13:45 ` [Bug tree-optimization/54935] " ysrumyan at gmail dot com
2012-10-15 14:06 ` rguenth at gcc dot gnu.org
2012-10-15 14:58 ` joseph at codesourcery dot com
2012-10-15 15:43 ` rguenther at suse dot de
2012-11-27  8:41 ` izamyatin at gmail dot com
2012-11-27  9:16 ` rguenth at gcc dot gnu.org
2021-07-21  3:25 ` pinskia 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).