Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

DJGPP/GCC 4.6.2 invalid code generation when -march restrict (Developers)

posted by RayeR Homepage, CZ, 10.04.2012, 00:38
(edited by RayeR on 10.04.2012, 02:00)

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:

Back to the forum
Board view  Mix view
22049 Postings in 2034 Threads, 396 registered users, 252 users online (1 registered, 251 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum