public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ysrumyan at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/54935] New: No way to do if converison
Date: Mon, 15 Oct 2012 13:26:00 -0000	[thread overview]
Message-ID: <bug-54935-4@http.gcc.gnu.org/bugzilla/> (raw)


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);
}


             reply	other threads:[~2012-10-15 13:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-15 13:26 ysrumyan at gmail dot com [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-54935-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).