On Wed, Oct 09, 2019 at 02:40:42PM +0100, Jozef Lawrynowicz wrote:
> I've added a new define_expand for msp430 to handle "mulhisi", but when 
> testing
> the changes, some builtin tests (e.g. builtin-arith-overflow-{1,5,p-1}.c) 
> fail.
> 
> I've narrowed a test case down to:
> 
> void
> foo (unsigned int r, unsigned int y)
> {
>   __builtin_umul_overflow ((unsigned int) (-1), y, &r);
> }
> 
> > msp430-elf-gcc -S tester.c -O0
> 
> tester.c: In function 'foo':
> tester.c:4:1: error: unrecognizable insn:
>     4 | }
>       | ^
> (insn 16 15 17 2 (set (reg:HI 32)
>         (const_int 65535 [0xffff])) "tester.c":3:3 -1
>      (nil))

Yes, that is not valid, it needs to be (const_int -1).

> I guess the bug is wherever the (const_int 65535) is generated, it should be 
> -1
> sign extend to a HWI. That is based on this statement from the docs:

Yes.  You need to debug where it is created ((const_int 65535) itself is not
wrong if it is e.g. meant for SImode or DImode etc., but when it is to be
used in HImode context, it needs to be canonicalized) and fix.

        Jakub

Reply via email to