public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/24929] long long shift/mask operations should be better optimized
[not found] <bug-24929-4@http.gcc.gnu.org/bugzilla/>
@ 2021-08-29 22:39 ` pinskia at gcc dot gnu.org
0 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-29 22:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=24929
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |4.3.0
Resolution|--- |FIXED
Status|NEW |RESOLVED
Keywords| |missed-optimization
--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed a long time ago.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug middle-end/24929] long long shift/mask operations should be better optimized
2005-11-18 2:30 [Bug middle-end/24929] New: " tkho at ucla dot edu
` (5 preceding siblings ...)
2006-09-20 22:20 ` steven at gcc dot gnu dot org
@ 2009-06-04 18:18 ` aldot at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: aldot at gcc dot gnu dot org @ 2009-06-04 18:18 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from aldot at gcc dot gnu dot org 2009-06-04 18:18 -------
(In reply to comment #5)
> movzbl 18(%esp), %eax
>
> could be used in this particular case.
4.3.3 onward seem to do that. Fixed?
$ for i in 4.2 4.3 4.4 4.5.orig-HEAD;do printf "### %s\n" $(gcc-$i
-dumpversion) ; gcc-$i -march=i386 -O2 -S -o- pr24929.c -fomit-frame-pointer |
awk 'BEGIN{yep=0;}/^f:/{yep=1;}/^\./{yep=0;}{if (yep){print $0}}';done
### 4.2.4
f:
pushl %edi
pushl %esi
pushl %ebx
movl 16(%esp), %esi
movl 20(%esp), %edi
movl 24(%esp), %ecx
movl 28(%esp), %ebx
movl %ebx, %ecx
xorl %ebx, %ebx
shrl $16, %ecx
movzbl %cl,%eax
xorl %edx, %edx
shldl $8, %esi, %edi
sall $8, %esi
orl %esi, %eax
orl %edi, %edx
popl %ebx
popl %esi
popl %edi
ret
.size f, .-f
.p2align 2,,3
### 4.3.3
f:
movl 4(%esp), %edx
movl 8(%esp), %ecx
shldl $8, %edx, %ecx
sall $8, %edx
movzbl 18(%esp), %eax
orl %edx, %eax
movl %ecx, %edx
ret
.size f, .-f
.p2align 2,,3
### 4.4.0
f:
movl 4(%esp), %edx
movl 8(%esp), %ecx
shldl $8, %edx, %ecx
sall $8, %edx
movzbl 18(%esp), %eax
orl %edx, %eax
movl %ecx, %edx
ret
.size f, .-f
.p2align 2,,3
### 4.5.0
f:
movl 4(%esp), %edx
movl 8(%esp), %ecx
shldl $8, %edx, %ecx
sall $8, %edx
movzbl 18(%esp), %eax
orl %edx, %eax
movl %ecx, %edx
ret
.size f, .-f
.p2align 2,,3
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24929
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug middle-end/24929] long long shift/mask operations should be better optimized
2005-11-18 2:30 [Bug middle-end/24929] New: " tkho at ucla dot edu
` (4 preceding siblings ...)
2006-06-27 13:02 ` uros at kss-loka dot si
@ 2006-09-20 22:20 ` steven at gcc dot gnu dot org
2009-06-04 18:18 ` aldot at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: steven at gcc dot gnu dot org @ 2006-09-20 22:20 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from steven at gcc dot gnu dot org 2006-09-20 22:19 -------
*** Bug 28405 has been marked as a duplicate of this bug. ***
--
steven at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |vda dot linux at googlemail
| |dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24929
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug middle-end/24929] long long shift/mask operations should be better optimized
2005-11-18 2:30 [Bug middle-end/24929] New: " tkho at ucla dot edu
` (3 preceding siblings ...)
2006-06-27 7:39 ` ian at airs dot com
@ 2006-06-27 13:02 ` uros at kss-loka dot si
2006-09-20 22:20 ` steven at gcc dot gnu dot org
2009-06-04 18:18 ` aldot at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: uros at kss-loka dot si @ 2006-06-27 13:02 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from uros at kss-loka dot si 2006-06-27 10:12 -------
(In reply to comment #4)
> which may be optimal.
movzbl 18(%esp), %eax
could be used in this particular case.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24929
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug middle-end/24929] long long shift/mask operations should be better optimized
2005-11-18 2:30 [Bug middle-end/24929] New: " tkho at ucla dot edu
` (2 preceding siblings ...)
2006-02-02 18:16 ` pinskia at gcc dot gnu dot org
@ 2006-06-27 7:39 ` ian at airs dot com
2006-06-27 13:02 ` uros at kss-loka dot si
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: ian at airs dot com @ 2006-06-27 7:39 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from ian at airs dot com 2006-06-27 06:05 -------
With my current version of the lower-subreg patch, I get this with -O2
-momit-leaf-frame-pointer:
f:
movl 16(%esp), %eax
movl 4(%esp), %ecx
movl 8(%esp), %edx
shrl $16, %eax
andl $255, %eax
shldl $8, %ecx, %edx
sall $8, %ecx
orl %ecx, %eax
ret
which may be optimal.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24929
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug middle-end/24929] long long shift/mask operations should be better optimized
2005-11-18 2:30 [Bug middle-end/24929] New: " tkho at ucla dot edu
2005-11-18 2:35 ` [Bug middle-end/24929] " tkho at ucla dot edu
2006-02-02 18:14 ` ian at airs dot com
@ 2006-02-02 18:16 ` pinskia at gcc dot gnu dot org
2006-06-27 7:39 ` ian at airs dot com
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-02-02 18:16 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from pinskia at gcc dot gnu dot org 2006-02-02 18:16 -------
Confirmed.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2006-02-02 18:16:13
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24929
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug middle-end/24929] long long shift/mask operations should be better optimized
2005-11-18 2:30 [Bug middle-end/24929] New: " tkho at ucla dot edu
2005-11-18 2:35 ` [Bug middle-end/24929] " tkho at ucla dot edu
@ 2006-02-02 18:14 ` ian at airs dot com
2006-02-02 18:16 ` pinskia at gcc dot gnu dot org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: ian at airs dot com @ 2006-02-02 18:14 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from ian at airs dot com 2006-02-02 18:14 -------
With an updated version of RTH's subreg lowering pass, I get this instruction
sequence:
f:
movl 16(%esp), %eax
movl 4(%esp), %edx
movl 8(%esp), %ecx
shrl $16, %eax
andl $255, %eax
shldl $8, %edx, %ecx
sall $8, %edx
orl %edx, %eax
movl %ecx, %edx
ret
This is one instruction shorter than the icc sequence, due to the use of shldl.
It could be improved by switching the roles of %ecx and %edx to avoid the
final move, although that is complex to implement give the way the register
allocator currently handles pseudo-registers larger than word mode.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24929
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug middle-end/24929] long long shift/mask operations should be better optimized
2005-11-18 2:30 [Bug middle-end/24929] New: " tkho at ucla dot edu
@ 2005-11-18 2:35 ` tkho at ucla dot edu
2006-02-02 18:14 ` ian at airs dot com
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: tkho at ucla dot edu @ 2005-11-18 2:35 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from tkho at ucla dot edu 2005-11-18 02:35 -------
Created an attachment (id=10273)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=10273&action=view)
shift/mask long long testcase
Here is a rough instruction-count comparison for f() compiled at -O2,
march=pentiumpro between icc9 and gcc head 20051108 with the patch in PR 17886,
comment #16:
icc: 11
gcc: 23
`icc -O2 -march=pentiumpro -S test3.c` gives:
movl 4(%esp), %eax
movl 8(%esp), %ecx
movl %eax, %edx
shrl $24, %edx
shll $8, %eax
shll $8, %ecx
orl %ecx, %edx
movzwl 18(%esp), %ecx
movzbl %cl, %ecx
orl %ecx, %eax
ret
`gcc -c test3.c -save-temps -O2 -march=pentiumpro -momit-leaf-frame-pointer`
gives:
subl $12, %esp
movl %edi, 8(%esp)
movl 28(%esp), %edi
movl 16(%esp), %eax
movl 20(%esp), %edx
movl %esi, 4(%esp)
movl 24(%esp), %esi
movl %edi, %esi
xorl %edi, %edi
movl 8(%esp), %edi
movl %ebx, (%esp)
shrl $16, %esi
xorl %ebx, %ebx
shldl $8, %eax, %edx
movl %esi, %ecx
movl 4(%esp), %esi
orl %ebx, %edx
movl (%esp), %ebx
andl $255, %ecx
sall $8, %eax
addl $12, %esp
orl %ecx, %eax
ret
For comparison, here's the code from gcc 2.95.3. It generates the same 18
instructions for both march=i386 and march=pentiumpro.
`gcc -c test3.c -save-temps -O2 -momit-leaf-frame-pointer -march=pentiumpro`:
pushl %ebx
movl 8(%esp),%ecx
movl 12(%esp),%ebx
movl 16(%esp),%eax
movl 20(%esp),%edx
shldl $8,%ecx,%ebx
sall $8,%ecx
movl %edx,%eax
xorl %edx,%edx
shrl $16,%eax
andl $255,%eax
andl $0,%edx
orl %eax,%ecx
orl %edx,%ebx
movl %ecx,%eax
movl %ebx,%edx
popl %ebx
ret
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24929
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-08-29 22:39 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-24929-4@http.gcc.gnu.org/bugzilla/>
2021-08-29 22:39 ` [Bug middle-end/24929] long long shift/mask operations should be better optimized pinskia at gcc dot gnu.org
2005-11-18 2:30 [Bug middle-end/24929] New: " tkho at ucla dot edu
2005-11-18 2:35 ` [Bug middle-end/24929] " tkho at ucla dot edu
2006-02-02 18:14 ` ian at airs dot com
2006-02-02 18:16 ` pinskia at gcc dot gnu dot org
2006-06-27 7:39 ` ian at airs dot com
2006-06-27 13:02 ` uros at kss-loka dot si
2006-09-20 22:20 ` steven at gcc dot gnu dot org
2009-06-04 18:18 ` aldot at gcc dot gnu dot 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).