public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug rtl-optimization/21150] New: Suboptimal byte extraction from larger integers @ 2005-04-21 13:10 vda at port dot imtp dot ilyichevsk dot odessa dot ua 2005-04-21 13:13 ` [Bug rtl-optimization/21150] " vda at port dot imtp dot ilyichevsk dot odessa dot ua ` (3 more replies) 0 siblings, 4 replies; 5+ messages in thread From: vda at port dot imtp dot ilyichevsk dot odessa dot ua @ 2005-04-21 13:10 UTC (permalink / raw) To: gcc-bugs Bytes are typically extracted from e.g. u64's by something like #define D5(v) (((v) >> 40) & 0xff) Testcase shows that gcc does not optimize this "good enough". -- Summary: Suboptimal byte extraction from larger integers Product: gcc Version: 3.4.3 Status: UNCONFIRMED Severity: normal Priority: P2 Component: rtl-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: vda at port dot imtp dot ilyichevsk dot odessa dot ua CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: i386-pc-linux-gnu GCC host triplet: i386-pc-linux-gnu GCC target triplet: i386-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21150 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug rtl-optimization/21150] Suboptimal byte extraction from larger integers 2005-04-21 13:10 [Bug rtl-optimization/21150] New: Suboptimal byte extraction from larger integers vda at port dot imtp dot ilyichevsk dot odessa dot ua @ 2005-04-21 13:13 ` vda at port dot imtp dot ilyichevsk dot odessa dot ua 2005-04-21 13:19 ` [Bug rtl-optimization/21150] Suboptimal byte extraction from 64bits pinskia at gcc dot gnu dot org ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: vda at port dot imtp dot ilyichevsk dot odessa dot ua @ 2005-04-21 13:13 UTC (permalink / raw) To: gcc-bugs ------- Additional Comments From vda at port dot imtp dot ilyichevsk dot odessa dot ua 2005-04-21 13:12 ------- Created an attachment (id=8701) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=8701&action=view) generate assembly with -S and compare results -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21150 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug rtl-optimization/21150] Suboptimal byte extraction from 64bits 2005-04-21 13:10 [Bug rtl-optimization/21150] New: Suboptimal byte extraction from larger integers vda at port dot imtp dot ilyichevsk dot odessa dot ua 2005-04-21 13:13 ` [Bug rtl-optimization/21150] " vda at port dot imtp dot ilyichevsk dot odessa dot ua @ 2005-04-21 13:19 ` pinskia at gcc dot gnu dot org 2005-04-24 13:26 ` vda at port dot imtp dot ilyichevsk dot odessa dot ua 2005-07-04 22:21 ` pinskia at gcc dot gnu dot org 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu dot org @ 2005-04-21 13:19 UTC (permalink / raw) To: gcc-bugs -- What |Removed |Added ---------------------------------------------------------------------------- Keywords| |missed-optimization Summary|Suboptimal byte extraction |Suboptimal byte extraction |from larger integers |from 64bits http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21150 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug rtl-optimization/21150] Suboptimal byte extraction from 64bits 2005-04-21 13:10 [Bug rtl-optimization/21150] New: Suboptimal byte extraction from larger integers vda at port dot imtp dot ilyichevsk dot odessa dot ua 2005-04-21 13:13 ` [Bug rtl-optimization/21150] " vda at port dot imtp dot ilyichevsk dot odessa dot ua 2005-04-21 13:19 ` [Bug rtl-optimization/21150] Suboptimal byte extraction from 64bits pinskia at gcc dot gnu dot org @ 2005-04-24 13:26 ` vda at port dot imtp dot ilyichevsk dot odessa dot ua 2005-07-04 22:21 ` pinskia at gcc dot gnu dot org 3 siblings, 0 replies; 5+ messages in thread From: vda at port dot imtp dot ilyichevsk dot odessa dot ua @ 2005-04-24 13:26 UTC (permalink / raw) To: gcc-bugs ------- Additional Comments From vda at port dot imtp dot ilyichevsk dot odessa dot ua 2005-04-24 13:26 ------- I don't think that bug description is correct. I believe similar observation will be valid for byte extraction from u32 and u16, and for u16-from-u32, etc. Update for latest gcc. This is what 4.0.0 produces from the testcase: # gcc -O2 -fomit-frame-pointer -S helper.c # cat helper.s [I removed non-essential stuff] a: movl v+8, %eax shrl $8, %eax xorb v, %al xorb v+18, %al xorb v+27, %al xorb v+36, %al movl v+40, %edx movl v+44, %ecx movl %ecx, %edx xorl %ecx, %ecx shrl $8, %edx xorl %edx, %eax xorb v+54, %al xorb v+63, %al movzbl %al, %eax ret b: movl v+8, %eax movl v+12, %edx shrdl $8, %edx, %eax shrl $8, %edx xorb v, %al movl v+16, %edx movl v+20, %ecx shrdl $16, %ecx, %edx shrl $16, %ecx xorl %edx, %eax movl v+24, %edx movl v+28, %ecx shrdl $24, %ecx, %edx shrl $24, %ecx xorl %edx, %eax xorb v+36, %al movl v+40, %edx movl v+44, %ecx movl %ecx, %edx xorl %ecx, %ecx shrl $8, %edx xorl %edx, %eax xorb v+54, %al xorb v+63, %al movzbl %al, %eax ret c: movb v+9, %al xorb v, %al xorb v+18, %al xorb v+27, %al xorb v+36, %al xorb v+45, %al xorb v+54, %al xorb v+63, %al movzbl %al, %eax ret d: movl v+8, %eax movl v+12, %edx shrdl $8, %edx, %eax shrl $8, %edx xorb v, %al movl v+16, %edx movl v+20, %ecx shrdl $16, %ecx, %edx shrl $16, %ecx xorl %edx, %eax movl v+24, %edx movl v+28, %ecx shrdl $24, %ecx, %edx shrl $24, %ecx xorl %edx, %eax xorb v+36, %al movl v+40, %edx movl v+44, %ecx movl %ecx, %edx xorl %ecx, %ecx shrl $8, %edx xorl %edx, %eax xorb v+54, %al xorb v+63, %al movzbl %al, %eax ret As you can see, a,b and d results are far from optimal, while c is almost perfect. Note that people typically use d, i.e. this: #define D7(v) (((v) >> 56)) #define D6(v) (((v) >> 48) & 0xff) #define D5(v) (((v) >> 40) & 0xff) #define D4(v) (((v) >> 32) & 0xff) #define D3(v) (((v) >> 24) & 0xff) #define D2(v) (((v) >> 16) & 0xff) #define D1(v) (((v) >> 8) & 0xff) #define D0(v) ((v) & 0xff) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21150 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug rtl-optimization/21150] Suboptimal byte extraction from 64bits 2005-04-21 13:10 [Bug rtl-optimization/21150] New: Suboptimal byte extraction from larger integers vda at port dot imtp dot ilyichevsk dot odessa dot ua ` (2 preceding siblings ...) 2005-04-24 13:26 ` vda at port dot imtp dot ilyichevsk dot odessa dot ua @ 2005-07-04 22:21 ` pinskia at gcc dot gnu dot org 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu dot org @ 2005-07-04 22:21 UTC (permalink / raw) To: gcc-bugs ------- Additional Comments From pinskia at gcc dot gnu dot org 2005-07-04 22:21 ------- Confirmed, this is most likely a sub register problem. -- What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever Confirmed| |1 Last reconfirmed|0000-00-00 00:00:00 |2005-07-04 22:21:33 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21150 ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-07-04 22:21 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2005-04-21 13:10 [Bug rtl-optimization/21150] New: Suboptimal byte extraction from larger integers vda at port dot imtp dot ilyichevsk dot odessa dot ua 2005-04-21 13:13 ` [Bug rtl-optimization/21150] " vda at port dot imtp dot ilyichevsk dot odessa dot ua 2005-04-21 13:19 ` [Bug rtl-optimization/21150] Suboptimal byte extraction from 64bits pinskia at gcc dot gnu dot org 2005-04-24 13:26 ` vda at port dot imtp dot ilyichevsk dot odessa dot ua 2005-07-04 22:21 ` pinskia 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).