public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "uweigand at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/47299] New: Widening multiply optimization generates bad code Date: Fri, 14 Jan 2011 21:34:00 -0000 [thread overview] Message-ID: <bug-47299-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47299 Summary: Widening multiply optimization generates bad code Product: gcc Version: 4.5.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: rtl-optimization AssignedTo: unassigned@gcc.gnu.org ReportedBy: uweigand@gcc.gnu.org CC: bernds@codesourcery.com, rguenther@suse.de Building the following test case with current mainline on i386: unsigned short test (unsigned char val) __attribute__ ((noinline)); unsigned short test (unsigned char val) { return val * 255; } int main(int argc, char**argv) { printf ("test(val=40) = %x\n", test(0x40)); return 0; } We get the following (correct) output with -O0: test(val=40) = 3fc0 and the following incorrect output with -O2: test(val=40) = ffc0 The problem appears to be related to this piece of code in expand_expr_real2, case WIDEN_MULT_EXPR: expand_operands (treeop0, treeop1, NULL_RTX, &op0, &op1, EXPAND_NORMAL); temp = expand_widening_mult (mode, op0, op1, target, unsignedp, this_optab); expand_operands will expand the constant 255 into QImode and return a (const_int -1) for op1. Passing this constant into expand_widening_mult then apparently generates a simple negation operation in HImode instead (via expand_const_mult) ... It seems this code came in here: http://gcc.gnu.org/ml/gcc-patches/2010-04/msg01327.html Any suggestions how this ought to be handled?
next reply other threads:[~2011-01-14 21:11 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2011-01-14 21:34 uweigand at gcc dot gnu.org [this message] 2011-01-14 22:22 ` [Bug rtl-optimization/47299] " rguenther at suse dot de 2011-01-16 4:10 ` doko at ubuntu dot com 2011-01-16 15:58 ` [Bug rtl-optimization/47299] [4.6 Regression] " hjl.tools at gmail dot com 2011-01-16 16:40 ` jakub at gcc dot gnu.org 2011-01-17 11:32 ` jakub at gcc dot gnu.org 2011-01-17 23:52 ` doko at ubuntu dot com 2011-01-18 8:59 ` jakub at gcc dot gnu.org 2011-01-18 9:05 ` jakub at gcc dot gnu.org
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-47299-4@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).