DJGPP/GCC 4.6.2 invalid code generation when -march restrict (Developers)
This problem was discussed on DJGPP google group. I want to warn other users who didn't read it. I don't know if it may affect freepascal too (if it shares some optimize code with gcc or not)
I met this issue by my own when compiling FFMPEG for older machines - pentium1 and older. I used -march=pentium -mfpmath=387 -O3 opt. options for GCC and recompiled entire package that was cleaned up (any old code couldn't be used). My friend tested it on AMD K6 machine but he got crash during MKV compression. MPEG1 went OK. It was illegal opcode exception. So I objdumped the EXE and revealed tens of CMOV instruction (P6+) in the DASM as I expected:
1ec15d: 0f 4e 06 cmovle (%esi),%eax
1edf71: 0f 42 05 48 f2 c3 08 cmovb 0x8c3f248,%eax
1f334e: 0f 40 23 cmovo (%ebx),%esp
1f4b35: 0f 4a 05 b4 fe 61 ef cmovp 0xef61feb4,%eax
1f7969: 0f 43 2a cmovae (%edx),%ebp
1fd563: 0f 44 28 cmove (%eax),%ebp
4024e3: 0f 42 0f cmovb (%edi),%ecx
4024e7: 0f 44 0f cmove (%edi),%ecx
4024ef: 0f 48 0f cmovs (%edi),%ecx
4024f7: 0f 4c 0f cmovl (%edi),%ecx
410f31: 0f 41 00 cmovno (%eax),%eax
49af38: 0f 4f 2f cmovg (%edi),%ebp
5c275d: 0f 47 3f cmova (%edi),%edi
...
I wonder that this bug is known for 1 year and still not fixed. So be carefull if you use new GCC to produce code that must run on older machines! I will try some older versions that I had archived and check objdump when CMOV disappear. Other option may be disable -O but it's not propably good idea.
This problem also make me thinking about if there exist some x86 assembler code analyser that will recogize what instruction is supported on what CPU and will return minimum CPU type that given code will run OK. Do you know about something like this?
EDIT:
I tried objdump *.a -d |grep cmov in my DJGPP\LIB and found that some system libs (like libm.a) are also poluted with CMOV, damn!
28.04.2002 01:44 152286 LIBAA.A
01.05.1994 15:42 178728 LIBBCC.A
25.10.2008 14:26 391330 LIBBFD.A
08.05.2011 20:29 782218 LIBGMP.A
13.02.2012 02:04 875212 LIBIBERT.A
21.03.2006 02:03 1191596 LIBICONV.A
19.08.2010 02:04 12904 LIBJB85.A
19.08.2010 02:04 43784 LIBJBIG.A
22.01.2012 02:04 729860 LIBLZMA.A
26.10.2011 10:42 199666 LIBM.A
08.05.2011 20:29 507476 LIBMP.A
19.05.2011 02:04 623148 LIBPNG.A
29.10.2011 10:33 494686 LIBQUADM.A
15.03.1998 16:42 252248 LIBVGA.A
24.01.2012 05:42 1494062 LIBWATT.A
19.02.2012 02:04 104236 LIBZ.A
---
DOS gives me freedom to unlimited HW access.
Complete thread:
- DJGPP/GCC 4.6.2 invalid code generation when -march restrict - RayeR, 10.04.2012, 00:38 (Developers)
- GCC 4.6.x invalid code generation - Rugxulo, 10.04.2012, 02:01
- GCC 4.6.x invalid code generation - RayeR, 10.04.2012, 03:58
- GCC 4.6.x invalid code generation - Rugxulo, 10.04.2012, 05:58
- GCC 4.6.x invalid code generation - RayeR, 10.04.2012, 13:44
- GCC 4.6.x invalid code generation - marcov, 10.04.2012, 16:19
- GCC 4.6.x invalid code generation - RayeR, 10.04.2012, 17:44
- GCC 4.6.x invalid code generation - RayeR, 14.04.2012, 23:28
- GCC 4.6.x invalid code generation: MP [PATCH] configure cmov - Arjay, 15.04.2012, 09:05
- GCC 4.6.x invalid code generation: MP [PATCH] configure cmov - RayeR, 15.04.2012, 14:44
- GCC 4.6.x invalid code generation: MP [PATCH] configure cmov - RayeR, 26.04.2012, 01:50
- GCC 4.6.x invalid code generation - Rugxulo, 26.04.2012, 09:06
- GCC 4.6.x invalid code generation - RayeR, 28.04.2012, 02:14
- x264 0.124 update - RayeR, 01.05.2012, 17:57
- CMOVNTQ and multiple file access - DOS386, 16.06.2012, 12:53
- Multiple file access, FreeDOS file locking support - ecm, 16.06.2012, 14:31
- multiple file access / IUP 0.67 - Rugxulo, 16.06.2012, 17:48
- multiple file access / IUP 0.67 - DOS386, 17.06.2012, 09:33
- CMOVNTQ and multiple file access - RayeR, 19.06.2012, 20:38
- CMOVNTQ and multiple file access - RayeR, 21.06.2012, 04:32
- load SHARE - ecm, 21.06.2012, 05:06
- load SHARE - RayeR, 21.06.2012, 12:40
- load SHARE - ecm, 21.06.2012, 12:47
- load SHARE - RayeR, 21.06.2012, 19:58
- load SHARE - RayeR, 21.06.2012, 23:31
- load SHARE - ecm, 22.06.2012, 14:03
- load SHARE - RayeR, 21.06.2012, 19:58
- load SHARE - ecm, 21.06.2012, 12:47
- load SHARE - RayeR, 21.06.2012, 12:40
- load SHARE - ecm, 21.06.2012, 05:06
- CMOVNTQ and multiple file access - RayeR, 21.06.2012, 04:32
- GCC 4.6.x invalid code generation - RayeR, 28.04.2012, 02:14
- GCC 4.6.x invalid code generation - Rugxulo, 26.04.2012, 09:06
- GCC 4.6.x invalid code generation: MP [PATCH] configure cmov - RayeR, 26.04.2012, 01:50
- GCC 4.6.x invalid code generation: MP [PATCH] configure cmov - RayeR, 15.04.2012, 14:44
- GCC 4.6.x invalid code generation: MP [PATCH] configure cmov - Arjay, 15.04.2012, 09:05
- GCC 4.6.x invalid code generation - RayeR, 14.04.2012, 23:28
- GCC 4.6.x invalid code generation - RayeR, 10.04.2012, 17:44
- GCC 4.6.x invalid code generation - marcov, 10.04.2012, 16:19
- GCC 4.6.x invalid code generation - RayeR, 10.04.2012, 13:44
- GCC 4.6.x invalid code generation - Rugxulo, 10.04.2012, 05:58
- GCC 4.6.x invalid code generation - marcov, 10.04.2012, 16:16
- GCC 4.6.x invalid code generation - RayeR, 10.04.2012, 17:49
- GCC 4.6.x invalid code generation - RayeR, 10.04.2012, 03:58
- GCC 4.6.x invalid code generation - Rugxulo, 10.04.2012, 02:01