public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/94234] New: missed ccp folding for (addr + 8 * n) - (addr + 8 * (n - 1))
@ 2020-03-20 11:14 fxue at os dot amperecomputing.com
  2020-03-20 14:16 ` [Bug tree-optimization/94234] " rguenth at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: fxue at os dot amperecomputing.com @ 2020-03-20 11:14 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94234

            Bug ID: 94234
           Summary: missed ccp folding for (addr + 8 * n) - (addr + 8 * (n
                    - 1))
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fxue at os dot amperecomputing.com
  Target Milestone: ---

CCP could not fold the following expression to a constant "8":

size_t foo (char *a, size_t n)
{
  char *b1 = a + 8 * n;
  char *b2 = a + 8 * (n - 1);

  return b1 - b2;
}

But if we change b1 and b2 to integer type, folding happens.

size_t foo (char *a, size_t n)
{
  size_t b1 = (size_t)(a + 8 * n);
  size_t b2 = (size_t)(a + 8 * (n - 1));

  return b1 - b2;
}

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

end of thread, other threads:[~2020-09-16  2:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-20 11:14 [Bug tree-optimization/94234] New: missed ccp folding for (addr + 8 * n) - (addr + 8 * (n - 1)) fxue at os dot amperecomputing.com
2020-03-20 14:16 ` [Bug tree-optimization/94234] " rguenth at gcc dot gnu.org
2020-03-20 15:50 ` glisse at gcc dot gnu.org
2020-08-19 14:30 ` cvs-commit at gcc dot gnu.org
2020-09-15  3:15 ` cvs-commit at gcc dot gnu.org
2020-09-15 14:55 ` cvs-commit at gcc dot gnu.org
2020-09-16  2:30 ` fxue at os dot amperecomputing.com

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