This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/54969] New: Bitfield test not optimised at -Os.
- From: "suckfish at ihug dot co.nz" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 18 Oct 2012 08:40:24 +0000
- Subject: [Bug middle-end/54969] New: Bitfield test not optimised at -Os.
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54969
Bug #: 54969
Summary: Bitfield test not optimised at -Os.
Classification: Unclassified
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: suckfish@ihug.co.nz
Compiling with -Os, the compiler fails to detect that this loop will always
execute at least once:
unsigned get (void);
void go (void)
{
unsigned f;
for (f = 1; f & 1; f = get());
}
The relevant assembly output:
jmp .L2
.L3:
call get
.L2:
testb $1, %al
jne .L3
With -O2 gcc does better, and removes the first jmp, giving:
.L2:
call get
testb $1, %al
jne .L2
This happens both on x86-64 and arm:
gcc (GCC) 4.7.2 20120921 (Red Hat 4.7.2-2)
arm-linux-gnu-gcc (GCC) 4.7.1 20120606 (Red Hat 4.7.1-0.1.20120606)