public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/67089] New: [4.8/4.9/5/6 Regression] Integer overflow checks not optimized on x86/x86_64
@ 2015-08-01 10:59 m.mukovnikov at gmail dot com
  2015-08-03  8:37 ` [Bug target/67089] " m.mukovnikov at gmail dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: m.mukovnikov at gmail dot com @ 2015-08-01 10:59 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 67089
           Summary: [4.8/4.9/5/6 Regression] Integer overflow checks not
                    optimized on x86/x86_64
           Product: gcc
           Version: 5.2.1
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: m.mukovnikov at gmail dot com
  Target Milestone: ---

Starting from 4.8.3, gcc does not optimize integer overflow and underflow
checks inserting a redundant cmp instruction in both 32-bit and 64-bit modes.
Having git-bisected the revisions, I found out r204088 (by pr58779) had added
such behavior.

--------------- example ---------------
extern void underflow(void) __attribute__((noreturn));
unsigned sub(unsigned a, unsigned b)
{
    unsigned r = a - b;
    if (r > a) underflow();
    return r;
}
------------ gcc-4.8.2 -O1 ------------
sub(unsigned int, unsigned int):
    movl    %edi, %eax
    subl    %esi, %eax /* CF is set on overflow */
    jae .L4            /* jae = jnb = jnc = 73h */
    subq    $8, %rsp
    call    underflow()
.L4:
    rep; ret
------------ gcc-4.8.3 -O1 ------------
sub(unsigned int, unsigned int):
    movl    %edi, %eax
    subl    %esi, %eax
    cmpl    %eax, %edi  /* absolutely redundant */
    jnb .L4
    subq    $8, %rsp
    call    underflow()
.L4:
    rep ret
---------------------------------------


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

end of thread, other threads:[~2015-10-16  8:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-01 10:59 [Bug target/67089] New: [4.8/4.9/5/6 Regression] Integer overflow checks not optimized on x86/x86_64 m.mukovnikov at gmail dot com
2015-08-03  8:37 ` [Bug target/67089] " m.mukovnikov at gmail dot com
2015-08-03  9:36 ` ubizjak at gmail dot com
2015-10-16  8:26 ` [Bug target/67089] [4.9/5/6 " rguenth 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).