[Bug tree-optimization/57503] [6/7/8 Regression] Wrong extension of multiply multiply operand
gjl at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Jan 15 14:49:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57503
Georg-Johann Lay <gjl at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|middle-end |tree-optimization
Summary|[6/7/8 Regression] Expand |[6/7/8 Regression] Wrong
|uses wrong multiply routine |extension of multiply
| |multiply operand
--- Comment #16 from Georg-Johann Lay <gjl at gcc dot gnu.org> ---
Presumably a bug in VRP, at least with
$ avr-gcc-8 -S -Os pr57503.c -mmcu=atmega8 -fdump-rtl-expand -fno-tree-vrp
the .expand dump is correct and reads as follows:
(note 5 4 8 2 NOTE_INSN_FUNCTION_BEG)
(insn 8 5 9 2 (set (reg:HI 49 [ ab ])
(mult:HI (zero_extend:HI (reg/v:QI 45 [ a ]))
(zero_extend:HI (reg/v:QI 46 [ b ])))) "pr57503.c":4 -1
(nil))
(insn 9 8 10 2 (parallel [
(set (reg:SI 48)
(mult:SI (zero_extend:SI (reg:HI 49 [ ab ]))
(sign_extend:SI (reg/v:HI 47 [ c ]))))
(clobber (reg:HI 26 r26))
(clobber (reg:DI 18 r18))
]) "pr57503.c":5 -1
(nil))
With VRP in action, the code prior to .vrp1 reads:
func1 (unsigned char a, unsigned char b, int c)
{
unsigned int ab;
int _1;
int _2;
int _3;
long int _4;
long int _5;
long int _10;
<bb 2> [local count: 1073741825]:
_1 = (int) a_6(D);
_2 = (int) b_7(D);
_3 = _1 * _2;
ab_8 = (unsigned int) _3;
_4 = (long int) ab_8;
_5 = (long int) c_9(D);
_10 = _4 * _5;
return _10;
}
Then VRP changes the code as follows:
func1 (unsigned char a, unsigned char b, int c)
{
unsigned int ab;
int _1;
int _2;
int _3;
long int _4;
long int _5;
long int _10;
<bb 2> [local count: 1073741825]:
_1 = (int) a_6(D);
_2 = (int) b_7(D);
_3 = _1 * _2;
ab_8 = (unsigned int) _3;
_4 = (long int) _3;
_5 = (long int) c_9(D);
_10 = _4 * _5;
return _10;
}
Notice the _3 (of type int) instead ob ab_8 (of type unsigned int).
More information about the Gcc-bugs
mailing list