avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] odd behaviour with type casting


From: Georg-Johann Lay
Subject: Re: [avr-gcc-list] odd behaviour with type casting
Date: Fri, 24 Feb 2012 09:58:08 +0100
User-agent: Mozilla Thunderbird 1.0.7 (Windows/20050923)

Ilya Lesokhin schrieb:

Please don't forget to CC the lists.

I think you are wrong.

the following in avr.md is wrong:

;; "mulhisi3"
;; "umulhisi3"
(define_expand "<extend_u>mulhisi3"
  [(parallel [(set (match_operand:SI 0 "register_operand" "")
                   (mult:SI (any_extend:SI (match_operand:HI 1
"register_operand" ""))
                            (any_extend:SI (match_operand:HI 2
"register_operand" ""))))
              (clobber (reg:HI 26))
              (clobber (reg:DI 18))])]
  "AVR_HAVE_MUL"
  "")

This is code from 4.7. The problem above is reported against 4.5.

you cant multiply two signed numbers this way, for example: -1*-1=1
and in 32bit its correct:  0xffffffff*0xffffffff = 1 (mod 2^32)

but using 16bit multiplication you get: 0xffff*0xffff=FFFE0001  (mod
2^32)  != -1.

In a n = n*n multiplication, and if flags don't matter, it does not
matter if you take the numbers as signed or unsigned; just like that
does not matter for addition or subtraction.

Anyway, in the pattern you see a widening multiplication, not a n = n*n
vanilla one. The multiply is performed with 32 bits so that you get
 0xffff * 0x0001 = 0xffffffff for example.

Johann



reply via email to

[Prev in Thread] Current Thread [Next in Thread]