From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31205 invoked by alias); 7 Apr 2009 20:07:10 -0000 Received: (qmail 31164 invoked by uid 48); 7 Apr 2009 20:06:59 -0000 Date: Tue, 07 Apr 2009 20:07:00 -0000 Subject: [Bug tree-optimization/39683] New: -fstrict-overflow misses multiply in comparison X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "tkoenig at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2009-04/txt/msg00670.txt.bz2 The shift isn't necessary. This could have been re-coded as return (a-b)<2; with -fstrict-overflow. $ cat ga.c int foo(int a, int b) { return (a-b)*4 < 8; } $ gcc -S -O2 -fstrict-overflow ga.c $ cat ga.s .file "ga.c" .text .p2align 4,,15 .globl foo .type foo, @function foo: pushl %ebp movl %esp, %ebp movl 8(%ebp), %eax subl 12(%ebp), %eax popl %ebp sall $2, %eax cmpl $7, %eax setle %al movzbl %al, %eax ret .size foo, .-foo .ident "GCC: (GNU) 4.4.0 20090221 (experimental)" .section .note.GNU-stack,"",@progbits -- Summary: -fstrict-overflow misses multiply in comparison Product: gcc Version: 4.4.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: tkoenig at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39683