This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/57503] [4.7/4.8 Regression] Expand uses wrong multiply routine
- From: "gjl at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 03 Jun 2013 15:00:41 +0000
- Subject: [Bug middle-end/57503] [4.7/4.8 Regression] Expand uses wrong multiply routine
- Auto-submitted: auto-generated
- References: <bug-57503-4 at http dot gcc dot gnu dot org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57503
--- Comment #6 from Georg-Johann Lay <gjl at gcc dot gnu.org> ---
Created attachment 30252
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30252&action=edit
.165r.expand: dump file with -Os -mmcu=atmega168 -fno-expensive-optimizations
The tree-ssa part for widening_mul can be disabled by
-fno-expensive-optimizations, but the code is still wrong. Cf. the attached
.expand dump of
long
func1 (unsigned char a, unsigned char b, int c)
{
unsigned ab = a * b;
return (long) ab * c;
}
ab is computed in insn 10 with zero-extended inputs:
(insn 8 5 9 2 (set (reg:HI 53 [ D.1447 ])
(zero_extend:HI (reg/v:QI 49 [ a ]))) cecky.c:4 -1
(nil))
(insn 9 8 10 2 (set (reg:HI 54 [ D.1447 ])
(zero_extend:HI (reg/v:QI 50 [ b ]))) cecky.c:4 -1
(nil))
(insn 10 9 11 2 (set (reg:HI 55 [ D.1447 ])
(mult:HI (reg:HI 53 [ D.1447 ])
(reg:HI 54 [ D.1447 ]))) cecky.c:4 -1
This is correct, but then in insn 11 ab gets sign-extended even though it is
unsigned:
(insn 11 10 12 2 (set (reg:SI 56 [ D.1448 ])
(sign_extend:SI (reg:HI 55 [ D.1447 ]))) cecky.c:5 -1
(nil))
Insn combine combines this wrong extension into a widening multiplication.