This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/58741] New: x86: Better optimization for operations on global long long and long variables
- From: "asmtwiddler at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 15 Oct 2013 21:34:51 +0000
- Subject: [Bug target/58741] New: x86: Better optimization for operations on global long long and long variables
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58741
Bug ID: 58741
Summary: x86: Better optimization for operations on global long
long and long variables
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: asmtwiddler at gmail dot com
Hello all,
I am using the experimental branch as well as version 4.6.3 to compile the
following code using "gcc -S -O2 -Wall"
The code below produces inefficient assembly for x86 (i686-linux-gnu):
unsigned long long val;
unsigned long small;
unsigned long long example() {
return val | small;
}
Which gives the following assembly:
example:
movl small, %ecx
movl val, %eax
movl val+4, %edx
pushl %ebx
xorl %ebx, %ebx
orl %ecx, %eax
orl %ebx, %edx
popl %ebx
ret
A more efficient implementation could be (which is generated if "extern const"
is added to the val and small definitions):
example:
movl small, %eax
movl val+4, %edx
orl val, %eax
ret
This inefficiency also occurs if the bitwise-or is replaced with an bitwise-xor
or subtraction.
Thanks