public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "ubizjak at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/31248] New: Too much casting for char operands on tree level Date: Sat, 17 Mar 2007 19:09:00 -0000 [thread overview] Message-ID: <bug-31248-1649@http.gcc.gnu.org/bugzilla/> (raw) Following testcase produces unnecessary moves in short loop: --cut here-- char table[256]; int test(void) { char val = 0; int i; for (i = 0; i < 10; i++) val += table[i]; return val; } --cut here-- gcc -O2: test: .LFB2: movzbl table(%rip), %ecx movl $1, %edx .p2align 4,,7 .L2: (*) movl %ecx, %eax addb table(%rdx), %al addq $1, %rdx cmpq $10, %rdx (*) movl %eax, %ecx jne .L2 movsbl %al,%eax ret Those unneccesary moves (*) are generated due to many (spurious?) casts in optimized tree dump: test () { long unsigned int ivtmp.31; char val; unsigned char D.1985; <bb 2>: val = (char) (unsigned char) MEM[symbol: table]; ivtmp.31 = 1; <L0>:; D.1985 = (unsigned char) val + (unsigned char) MEM[symbol: table, index: ivtmp.31]; val = (char) D.1985; ivtmp.31 = ivtmp.31 + 1; if (ivtmp.31 != 10) goto <L0>; else goto <L2>; <L2>:; return (int) val; -- Summary: Too much casting for char operands on tree level Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ubizjak at gmail dot com GCC build triplet: x86_64-pc-linux-gnu GCC host triplet: x86_64-pc-linux-gnu GCC target triplet: x86_64-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31248
next reply other threads:[~2007-03-17 19:09 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2007-03-17 19:09 ubizjak at gmail dot com [this message] 2007-03-18 5:30 ` [Bug tree-optimization/31248] " pinskia at gcc dot gnu dot org 2007-03-29 6:16 ` [Bug rtl-optimization/31248] char adding gives an extra move or two pinskia at gcc dot gnu dot org 2007-08-28 12:02 ` [Bug rtl-optimization/31248] char adding (in loops) " ubizjak at gmail dot com 2008-01-09 9:29 ` ubizjak at gmail dot com 2008-01-09 9:46 ` ubizjak at gmail dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-31248-1649@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).