Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Compiler internal error] error: insn does not satisfy its constraints #29

Closed
alexalkis opened this issue Mar 25, 2018 · 23 comments
Closed

Comments

@alexalkis
Copy link

Looks like bebbo/amigaos-cross-toolchain#34 but I think it's a different error.

git clone https://github.com/alexalkis/a68k

m68k-amigaos-gcc -mcrt=nix13 -fbaserel -m68000 -msmall-code -o foo *.c

Symtab.c: In function ‘SubArgs’:
Symtab.c:494:1: error: insn does not satisfy its constraints:
}
^
(insn 388 6 75 (set (reg:SI 9 a1)
(plus:SI (reg/v/f:SI 2 d2 [orig:32 s ] [32])
(const_int 2 [0x2]))) 141 {addsi3_internal}
(nil))
Symtab.c:494:1: internal compiler error: in final_scan_insn, at final.c:2923
0xc33e59 _fatal_insn(char const
, rtx_def const*, char const*, int, char const*)
/home/alex/t/amigaos-cross-toolchain/submodules/gcc-6/gcc/rtl-error.c:108
0xc33eb9 _fatal_insn_not_found(rtx_def const*, char const*, int, char const*)
/home/alex/t/amigaos-cross-toolchain/submodules/gcc-6/gcc/rtl-error.c:118
0x934046 final_scan_insn(rtx_insn*, _IO_FILE*, int, int, int*)
/home/alex/t/amigaos-cross-toolchain/submodules/gcc-6/gcc/final.c:2923
0x93235a final(rtx_insn*, _IO_FILE*, int)
/home/alex/t/amigaos-cross-toolchain/submodules/gcc-6/gcc/final.c:2045
0x936ea9 rest_of_handle_final
/home/alex/t/amigaos-cross-toolchain/submodules/gcc-6/gcc/final.c:4455
0x9370a8 execute
/home/alex/t/amigaos-cross-toolchain/submodules/gcc-6/gcc/final.c:4530
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See http://gcc.gnu.org/bugs.html for instructions.

@alexalkis
Copy link
Author

m68k-amigaos-gcc -noixemul -Os -mcrt=nix13 -fbaserel -m68000 -msmall-code -o foo *.c

is the actual command that brings the error. Without -Os no internal error (but a lot of linker errors)

@bebbo
Copy link
Owner

bebbo commented Mar 25, 2018

(insn 388 6 75 (set (reg:SI 9 a1)
(plus:SI (reg/v/f:SI 2 d2 [orig:32 s ] [32])
(const_int 2 [0x2]))) 141 {addsi3_internal}
(nil))

This would result in lea 2(d2),a1 which is indeed invalid. And yes, it's a different issue.

@bebbo
Copy link
Owner

bebbo commented Mar 26, 2018

m68k-amigaos-gcc -noixemul -Os -mcrt=nix13 -fbaserel -m68000 -msmall-code -S Symtab.c

@bebbo
Copy link
Owner

bebbo commented Mar 26, 2018

I removed the attempt to combin the moved insn with the previous one.

Now this code:

	...
	addq.l #2,d2

.L22:
	move.l d2,a1
	move.b (a1)+,d0
	move.l a1,d2
	move.b d0,(a2)+
	jne .L22
	move.l a3,a2
	move.l a6,d1

.L23:
	move.l d1,a1
	move.b (a1)+,d0
	move.l a1,d1
	move.b d0,(a2)+
	jne .L23
	...

is correctly converted to:

	...
	addq.l #2,d2
	move.l d2,a1
.L22:
	move.b (a1)+,(a2)+
	jne .L22
	move.l a3,a2
	move.l a6,d0
	move.l d0,a1
.L23:
	move.b (a1)+,(a2)+
	jne .L23
	...

bebbo added a commit that referenced this issue Mar 26, 2018
@alexalkis
Copy link
Author

Ummm, doesn't commits get propagated to https://github.com/bebbo/amigaos-cross-toolchain ?
I keep doing git pull and nothing comes up. I have to switch, don't I? :)

@bebbo
Copy link
Owner

bebbo commented Mar 26, 2018

https://github.com/bebbo/amigaos-cross-toolchain is frozen

Please use https://github.com/bebbo/amiga-gcc.

  1. clone https://github.com/bebbo/amiga-gcc
  2. cd amiga-gcc
  3. make update
  4. make all -j4

you may export PREFIX=/what/u/want to specify your prefix.

@alexalkis
Copy link
Author

Ok, internal error fixed. The linker errors are "normal"?

@bebbo
Copy link
Owner

bebbo commented Mar 27, 2018

what errors?

@alexalkis
Copy link
Author

m68k-amigaos-gcc -noixemul -Os -mcrt=nix13 -fbaserel -m68000 -msmall-code -o foo *.c

INFO: using long jump from /tmp/cckabmEj.o to open.o:_close
INFO: using long jump from /tmp/cckabmEj.o to free.o:_free
INFO: using long jump from /tmp/cckabmEj.o to remove.o:_unlink
INFO: using long jump from /tmp/cckabmEj.o to fprintf.o:_fprintf
INFO: using long jump from /tmp/cckabmEj.o to printf.o:_printf
INFO: using long jump from /tmp/cckabmEj.o to malloc.o:_malloc
INFO: using long jump from /tmp/cckabmEj.o to __mulsi3.o:___mulsi3
INFO: using long jump from /tmp/cckabmEj.o to fflush.o:_fflush
INFO: using long jump from /tmp/cckabmEj.o to strcat.o:_strcat
INFO: using long jump from /tmp/cckabmEj.o to open.o:_lseek
INFO: using long jump from /tmp/cckabmEj.o to clock.o:_clock
INFO: using long jump from /tmp/cckabmEj.o to __udivsi3.o:___udivsi3
INFO: using long jump from /tmp/cckabmEj.o to strcmp.o:_strcmp
INFO: using long jump from /tmp/ccVzRo2H.o to /tmp/cckabmEj.o:_quit_cleanup
/home/alex/gcc6/m68k-amigaos/libnix/lib/libnix/nbcrt0.o(.text+0x70):/home/alex/gcc6/m68k-amigaos/libnix/lib/libnix/nbcrt0.o: multiple definition of _exit' /home/alex/gcc6/m68k-amigaos/libnix/lib/libnix/nbcrt0.o(.text+0x70):/home/alex/gcc6/m68k-amigaos/libnix/lib/libnix/nbcrt0.o: first defined here /home/alex/gcc6/m68k-amigaos/libnix/lib/libnix/nbcrt0.o(.text+0xcc):/home/alex/gcc6/m68k-amigaos/libnix/lib/libnix/nbcrt0.o: multiple definition of geta4'
/home/alex/gcc6/m68k-amigaos/libnix/lib/libnix/nbcrt0.o(.text+0xcc):/home/alex/gcc6/m68k-amigaos/libnix/lib/libnix/nbcrt0.o: first defined here
/home/alex/gcc6/m68k-amigaos/libnix/lib/libnix/nbcrt0.o(.text+0xcc):/home/alex/gcc6/m68k-amigaos/libnix/lib/libnix/nbcrt0.o: multiple definition of __restore_a4' /home/alex/gcc6/m68k-amigaos/libnix/lib/libnix/nbcrt0.o(.text+0xcc):/home/alex/gcc6/m68k-amigaos/libnix/lib/libnix/nbcrt0.o: first defined here /home/alex/gcc6/m68k-amigaos/libnix/lib/libb/libnix/libnix.a(malloc.o)(.text+0xf8):malloc.o: multiple definition of __exitmalloc'
/home/alex/gcc6/m68k-amigaos/libnix/lib/libb/libnix/libnix.a(malloc.o)(.text+0xf8):malloc.o: first defined here
/home/alex/gcc6/m68k-amigaos/libnix/lib/libb/libnix/libnix.a(malloc.o)(.text+0xc4):malloc.o: multiple definition of __initmalloc' /home/alex/gcc6/m68k-amigaos/libnix/lib/libb/libnix/libnix.a(malloc.o)(.text+0xc4):malloc.o: first defined here /home/alex/gcc6/m68k-amigaos/libnix/lib/libb/libnix/libnix.a(malloc.o)(.text+0x0):malloc.o: multiple definition of malloc'
/home/alex/gcc6/m68k-amigaos/libnix/lib/libb/libnix/libnix.a(malloc.o)(.text+0x0):malloc.o: first defined here
collect2: error: ld returned 1 exit status

@bebbo
Copy link
Owner

bebbo commented Mar 27, 2018

You must specify only one of

  • -mcrt=nix13
  • -mcrt=nix20
  • -noixemul
    otherwise you have the startup file and libs linked twice.

@alexalkis
Copy link
Author

Oh, thanks didn't know that.

It compiles with -mcrt=nix13 but if you run it you get nothing.

This gives output
m68k-amigaos-gcc -Os -noixemul -o foo *.c

This does not give any output
m68k-amigaos-gcc -Os -mcrt=nix13 -fbaserel -m68000 -msmall-code -o foo *.c

(Just type foo in an amigashell)

@bebbo
Copy link
Owner

bebbo commented Mar 27, 2018

Hm, libnix is not well tested for kickstart 13. Please open a ticket there.

@alexalkis
Copy link
Author

Thanks, will do.

@bebbo bebbo reopened this Mar 27, 2018
@bebbo
Copy link
Owner

bebbo commented Mar 27, 2018

it's related to -msmall-code. The linker does not adjust the entry points for the INIT_LIST properly.

=> instead of calling __initcommandline, the instrcution befor this function is called which is a jump to quit_cleanup...

@bebbo
Copy link
Owner

bebbo commented Mar 27, 2018

pushed a fix to binutils

@alexalkis
Copy link
Author

Umm, works on a1200. Crashes on a500 (guru 0000 0004)
Attached cause it might be my kickstart
foo.zip
1.3 enviroment again

@bebbo
Copy link
Owner

bebbo commented Mar 27, 2018

As I wrote, libnix is not well prepared for kick13...

... e.g using AllocVec... which is kick2.0+

@alexalkis
Copy link
Author

Hmmm, it uses constructs like that

#if defined(KICKSTART) && (KICKSTART<=34)
void * __alloc_vec(unsigned long sz, unsigned long flags);
void __free_vec(void *);
#define AllocVec(a,b) __alloc_vec(a,b)
#define FreeVec(a) __free_vec(a)
#endif

@alexalkis
Copy link
Author

alexalkis commented Mar 27, 2018

Makefile.in in nix13 directory has the following line
OPTIONS=-I$(srcdir)/../headers $(CFLAGS) -D__KICK13__

Shouldn't that define something like KICKSTART=33 also?

@bebbo
Copy link
Owner

bebbo commented Mar 28, 2018

I once started working on it, it's not finished and it's a libnix issue.

@alexalkis
Copy link
Author

I tried defining KICKSTART=34 in Makefile.in. It goes into the build/xxx/Makefile and I have planted a syntax error inside the "if defined" thing, but everything builds fine. So the "if defined" is not true for some reason.
Meh.

@bebbo
Copy link
Owner

bebbo commented Mar 28, 2018

There is more todo...
... I stopped my attempt since I figured that I first should build the full libnix lib with NDK13 to find all issues. Then I planned to patch the sys-include headers to hide all library functions which are not visible with kick13.
And last write wrappers for the missing functions and pack it into the libnix13.a.
...

@alexalkis
Copy link
Author

We established this is libnix. Closing this.

bebbo pushed a commit that referenced this issue Jan 21, 2024
Hi all,

We noticed that calls to the vadcq and vsbcq intrinsics, both of
which use __builtin_arm_set_fpscr_nzcvqc to set the Carry flag in
the FPSCR, would produce the following code:

```
< r2 is the *carry input >
vmrs	r3, FPSCR_nzcvqc
bic	r3, r3, #536870912
orr	r3, r3, r2, lsl #29
vmsr	FPSCR_nzcvqc, r3
```

when the MVE ACLE instead gives a different instruction sequence of:
```
< Rt is the *carry input >
VMRS Rs,FPSCR_nzcvqc
BFI Rs,Rt,#29,#1
VMSR FPSCR_nzcvqc,Rs
```

the bic + orr pair is slower and it's also wrong, because, if the
*carry input is greater than 1, then we risk overwriting the top two
bits of the FPSCR register (the N and Z flags).

This turned out to be a problem in the header file and the solution was
to simply add a `& 1x0u` to the `*carry` input: then the compiler knows
that we only care about the lowest bit and can optimise to a BFI.

Ok for trunk?

Thanks,
Stam Markianos-Wright

gcc/ChangeLog:

	* config/arm/arm_mve.h (__arm_vadcq_s32): Fix arithmetic.
	(__arm_vadcq_u32): Likewise.
	(__arm_vadcq_m_s32): Likewise.
	(__arm_vadcq_m_u32): Likewise.
	(__arm_vsbcq_s32): Likewise.
	(__arm_vsbcq_u32): Likewise.
	(__arm_vsbcq_m_s32): Likewise.
	(__arm_vsbcq_m_u32): Likewise.
	* config/arm/mve.md (get_fpscr_nzcvqc): Make unspec_volatile.

gcc/testsuite/ChangeLog:
	* gcc.target/arm/mve/mve_vadcq_vsbcq_fpscr_overwrite.c: New.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants