public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/58742] New: pointer arithmetic simplification
@ 2013-10-15 21:47 glisse at gcc dot gnu.org
  2013-10-18 11:57 ` [Bug tree-optimization/58742] " glisse at gcc dot gnu.org
                   ` (25 more replies)
  0 siblings, 26 replies; 27+ messages in thread
From: glisse at gcc dot gnu.org @ 2013-10-15 21:47 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 58742
           Summary: pointer arithmetic simplification
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: glisse at gcc dot gnu.org

int* f(int*b,int*e){
  return b+(e-b);
}

gives the following .optimized dump:

  e.0_2 = (long int) e_1(D);
  b.1_4 = (long int) b_3(D);
  _5 = e.0_2 - b.1_4;
  _6 = _5 /[ex] 4;
  _7 = (long unsigned int) _6;
  _8 = _7 * 4;
  _9 = b_3(D) + _8;
  return _9;

I believe the desired result is obvious enough...

At the asm level, this gives:

    subq    %rdi, %rsi
    movq    %rsi, %rax
    andq    $-4, %rax
    addq    %rdi, %rax

which seems to indicate that the exactness of the division was somehow lost
(otherwise the andq would disappear, and sub+add could then be simplified).


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

end of thread, other threads:[~2014-02-03 10:38 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-15 21:47 [Bug tree-optimization/58742] New: pointer arithmetic simplification glisse at gcc dot gnu.org
2013-10-18 11:57 ` [Bug tree-optimization/58742] " glisse at gcc dot gnu.org
2013-10-21  9:07 ` rguenth at gcc dot gnu.org
2013-10-21  9:38 ` [Bug middle-end/58742] [4.7/4.8/4.9 Regression] " rguenth at gcc dot gnu.org
2013-10-21 11:34 ` rguenth at gcc dot gnu.org
2013-10-22  8:26 ` glisse at gcc dot gnu.org
2013-10-23 11:42 ` [Bug middle-end/58742] [4.7/4.8 " rguenth at gcc dot gnu.org
2013-10-24 13:28 ` rguenth at gcc dot gnu.org
2013-11-18 15:13 ` rguenth at gcc dot gnu.org
2013-11-18 15:15 ` rguenth at gcc dot gnu.org
2013-11-18 15:21 ` [Bug middle-end/58742] " glisse at gcc dot gnu.org
2013-11-18 15:33 ` rguenth at gcc dot gnu.org
2013-11-18 15:34 ` rguenth at gcc dot gnu.org
2013-11-20 10:40 ` rguenth at gcc dot gnu.org
2013-11-20 10:57 ` glisse at gcc dot gnu.org
2014-01-21 12:15 ` glisse at gcc dot gnu.org
2014-01-28 10:13 ` rguenther at suse dot de
2014-01-28 14:54 ` rguenth at gcc dot gnu.org
2014-01-28 14:55 ` rguenth at gcc dot gnu.org
2014-01-28 15:24 ` rguenth at gcc dot gnu.org
2014-01-29 11:09 ` rguenth at gcc dot gnu.org
2014-01-29 12:25 ` rguenth at gcc dot gnu.org
2014-01-29 14:46 ` rguenth at gcc dot gnu.org
2014-01-29 14:46 ` rguenth at gcc dot gnu.org
2014-01-31 17:15 ` glisse at gcc dot gnu.org
2014-02-03  9:28 ` rguenth at gcc dot gnu.org
2014-02-03 10:38 ` rguenther at suse dot de

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