From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24939 invoked by alias); 7 Oct 2013 09:19:57 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 24773 invoked by uid 48); 7 Oct 2013 09:19:54 -0000 From: "gjl at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/57503] [4.7/4.8 Regression] Expand uses wrong multiply routine Date: Mon, 07 Oct 2013 09:19:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 4.7.2 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: gjl at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.7.4 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-10/txt/msg00383.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57503 Georg-Johann Lay changed: What |Removed |Added ---------------------------------------------------------------------------- Status|WAITING |NEW --- Comment #8 from Georg-Johann Lay --- (In reply to Richard Biener from comment #7) > Can you please investigate the behavior on current trunk and the top of the > 4.8 branch? Using the code from comment #7 the problem persists $ avr-gcc -S -Os pr57503.c -mmcu=atmega8 -dP long func1 (unsigned char a, unsigned char b, int c) { unsigned ab = a * b; return (long) ab * c; } The code is a bit different but still wrong: func1: ; (insn 10 5 25 (set (reg:HI 18 r18 [orig:44 D.1450 ] [44]) ; (mult:HI (zero_extend:HI (reg:QI 24 r24 [ a ])) ; (zero_extend:HI (reg/v:QI 22 r22 [orig:50 b ] [50])))) pr57503.c:4 168 {umulqihi3} ; (expr_list:REG_DEAD (reg:QI 24 r24 [ a ]) ; (expr_list:REG_DEAD (reg/v:QI 22 r22 [orig:50 b ] [50]) ; (nil)))) mul r24,r22 ; 10 umulqihi3 [length = 3] movw r18,r0 clr __zero_reg__ ; (insn 25 10 26 (set (reg:HI 26 r26) ; (reg/v:HI 20 r20 [orig:51 c ] [51])) pr57503.c:5 82 {*movhi} ; (expr_list:REG_DEAD (reg/v:HI 20 r20 [orig:51 c ] [51]) ; (nil))) movw r26,r20 ; 25 *movhi/1 [length = 1] ; (insn 26 25 21 (set (reg:SI 22 r22) ; (mult:SI (sign_extend:SI (reg:HI 18 r18)) ; (sign_extend:SI (reg:HI 26 r26)))) pr57503.c:5 231 {*mulhisi3_call} ; (expr_list:REG_DEAD (reg:HI 26 r26) ; (expr_list:REG_DEAD (reg:HI 18 r18) ; (nil)))) rcall __mulhisi3 ; 26 *mulhisi3_call [length = 1] ; (jump_insn 31 21 30 (return) pr57503.c:6 451 {return} ; (nil) ; -> return) ret ; 31 return [length = 1] Insn 26 sign-extends both inputs but R18 (unsigned ab) should be zero-extended. Tested with SVN 203240 gcc version 4.9.0 20131007 (experimental) (GCC)