mulhisi3 problem
Ian Lance Taylor
iant@google.com
Mon Dec 8 05:59:00 GMT 2008
Vít Mach-Žižka <V.Zizka@seznam.cz> writes:
> I'd like to add this "mulhisi3" pattern now:
> [(set (match_operand:SI 0 "register_operand" "=r")
> (mult:SI (match_operand:HI 1 "register_operand" "%r")
> (match_operand:HI 2 "register_operand" "r")))]
That is not valid RTL. You are doing a SImode multiplication of two
HImode values, which is meaningless. You must write something like
(mult:SI (sign_extend:SI (match_operand:HI ...))
(sign_extend:SI (match_operand:HI ...)))
> When I compile (with -O0, GCC 4.3.2), for example, this:
> void foo()
> {
> int a,b; /* int size is 16bit */
> long int c; /* long int size is 32bit - bits, bytes and word are big endian */
>
> a = 6535;
> b = 535;
> c = a * b;
> }
According to the rules of C, this is doing a 16-bit multiplication,
and then sign extending the 16-bit result to assign it to a 32-bit
variable. If you want to produce a 32-bit result, you must write
something like
c = (long) a * (long) b;
Ian
More information about the Gcc-help
mailing list