home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / gnu / gcc / bug / 1990 < prev    next >
Encoding:
Text File  |  1992-07-25  |  10.7 KB  |  362 lines

  1. Newsgroups: gnu.gcc.bug
  2. Path: sparky!uunet!cis.ohio-state.edu!ma2s2.mathematik.uni-karlsruhe.de!haible
  3. From: haible@ma2s2.mathematik.uni-karlsruhe.de (Bruno Haible)
  4. Subject: GCC -O2 for i386
  5. Message-ID: <9207252017.AA04106@ma2s2.mathematik.uni-karlsruhe.de>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: GNUs Not Usenet
  8. Distribution: gnu
  9. Date: Sun, 26 Jul 1992 00:17:38 GMT
  10. Approved: bug-gcc@prep.ai.mit.edu
  11. Lines: 349
  12.  
  13. I have found a bug in GCC's i386 code generation.
  14. I'm using GCC version 2.2.2, configured as i386-linux by H.J.Lu.
  15.  
  16. gcc -O -S array.i ; cat array.s
  17. is OK.
  18. gcc -O2 -S array.i ; cat array.s
  19. uncovers a bug: The instruction marked 'INCORRECT' uses %al, but
  20. %eax has not been set before, so contains garbage.
  21.  
  22. ======================= array.i ================================================
  23.   typedef char           BYTE;      
  24.   typedef unsigned char  UBYTE;     
  25.   typedef short          WORD;      
  26.   typedef unsigned short UWORD;     
  27.   typedef long           LONG;      
  28.   typedef unsigned long  ULONG;     
  29.   typedef unsigned int  boolean;
  30.   typedef signed int  signean;
  31.   typedef UBYTE   uint1;    
  32.   typedef BYTE    sint1;    
  33.   typedef UBYTE   uint2;    
  34.   typedef BYTE    sint2;    
  35.   typedef UBYTE   uint3;    
  36.   typedef BYTE    sint3;    
  37.   typedef UBYTE   uint4;    
  38.   typedef BYTE    sint4;    
  39.   typedef UBYTE   uint5;    
  40.   typedef BYTE    sint5;    
  41.   typedef UBYTE   uint6;    
  42.   typedef BYTE    sint6;    
  43.   typedef UBYTE   uint7;    
  44.   typedef BYTE    sint7;    
  45.   typedef UBYTE   uint8;    
  46.   typedef BYTE    sint8;    
  47.   typedef UWORD   uint9;    
  48.   typedef WORD    sint9;    
  49.   typedef UWORD   uint10;   
  50.   typedef WORD    sint10;   
  51.   typedef UWORD   uint11;   
  52.   typedef WORD    sint11;   
  53.   typedef UWORD   uint12;   
  54.   typedef WORD    sint12;   
  55.   typedef UWORD   uint13;   
  56.   typedef WORD    sint13;   
  57.   typedef UWORD   uint14;   
  58.   typedef WORD    sint14;   
  59.   typedef UWORD   uint15;   
  60.   typedef WORD    sint15;   
  61.   typedef UWORD   uint16;   
  62.   typedef WORD    sint16;   
  63.   typedef ULONG   uint17;   
  64.   typedef LONG    sint17;   
  65.   typedef ULONG   uint18;   
  66.   typedef LONG    sint18;   
  67.   typedef ULONG   uint19;   
  68.   typedef LONG    sint19;   
  69.   typedef ULONG   uint20;   
  70.   typedef LONG    sint20;   
  71.   typedef ULONG   uint21;   
  72.   typedef LONG    sint21;   
  73.   typedef ULONG   uint22;   
  74.   typedef LONG    sint22;   
  75.   typedef ULONG   uint23;   
  76.   typedef LONG    sint23;   
  77.   typedef ULONG   uint24;   
  78.   typedef LONG    sint24;   
  79.   typedef ULONG   uint25;   
  80.   typedef LONG    sint25;   
  81.   typedef ULONG   uint26;   
  82.   typedef LONG    sint26;   
  83.   typedef ULONG   uint27;   
  84.   typedef LONG    sint27;   
  85.   typedef ULONG   uint28;   
  86.   typedef LONG    sint28;   
  87.   typedef ULONG   uint29;   
  88.   typedef LONG    sint29;   
  89.   typedef ULONG   uint30;   
  90.   typedef LONG    sint30;   
  91.   typedef ULONG   uint31;   
  92.   typedef LONG    sint31;   
  93.   typedef ULONG   uint32;   
  94.   typedef LONG    sint32;   
  95.   typedef   sint8        sintB;
  96.   typedef   uint8      uintB;
  97.   typedef   sint16        sintW;
  98.   typedef   uint16      uintW;
  99.   typedef   sint32        sintL;
  100.   typedef   uint32      uintL;
  101.   typedef struct { sintL hi; uintL lo; } sintL2;  
  102.   typedef struct { uintL hi; uintL lo; } uintL2;  
  103.   typedef   sint16         sintBW;
  104.   typedef   uint16       uintBW;
  105.   typedef   sint32         sintWL;
  106.   typedef   uint32       uintWL;
  107.   typedef   sint32         sintBWL;
  108.   typedef   uint32       uintBWL;
  109.   typedef   uint32      uintD;
  110.   typedef   sint32        sintD;
  111.   typedef  void *  object;
  112.   typedef  uintL  oint;
  113. extern object* STACK; 
  114.   typedef   uint8      tint;
  115.   typedef   uint24      aint;
  116. typedef struct { union { object _GCself; uintB flags[4]; } header;   
  117.                  uintL  length;    
  118.                }
  119.         sarray_;
  120. typedef sarray_ *  Sarray;
  121. typedef struct { union { object _GCself; uintB flags[4]; } header;   
  122.                  uintL  length;    
  123.                  uint8  data[0 ];  
  124.                }
  125.         sbvector_;
  126. typedef sbvector_ *  Sbvector;
  127. typedef struct { union { object _GCself; uintB flags[4]; } header;   
  128.                  uintL  length;    
  129.                  uintB  data[0 ];  
  130.                }
  131.         sstring_;
  132. typedef sstring_ *  Sstring;
  133. typedef struct { union { object _GCself; uintB flags[4]; } header;   
  134.                  uintL  length;    
  135.                  object data[0 ];  
  136.                }
  137.         svector_;
  138. typedef svector_ *  Svector;
  139. typedef struct { union { object _GCself; uintB flags[4]; } header;    
  140.                  uintB flags;       
  141.                  uintWL  rank;        
  142.                  object data;       
  143.                  uintL totalsize;   
  144.                  uintL dims[0 ];  
  145.                }
  146.         array_;
  147. typedef array_ *  Array;
  148.     typedef void Values;
  149.     typedef Values (*lisp_function)();
  150.   typedef struct { lisp_function function;  
  151.                    object name;             
  152.                    object keywords;         
  153.                    uintW argtype;           
  154.                    uintW req_anz;           
  155.                    uintW opt_anz;           
  156.                    uintB rest_flag;         
  157.                    uintB key_flag;          
  158.                    uintW key_anz;           
  159.                  }
  160.           subr_;
  161.   typedef subr_ *  Subr;
  162.     extern uintWL  mv_count;
  163.   extern object mv_space [ 128 -1];
  164.     extern object subr_self;
  165.   extern  volatile  void fehler (const char * errorstring);
  166.    static   volatile  void fehler_vector (object obj);
  167.    static   volatile  void fehler_vector(    
  168.        register  object obj)
  169.     {  ( (STACK[-1-(-1)])  = (obj), STACK  -=  -1) ;  ( (STACK[-1-(-1)])  = ( ((Subr)(((0 ==0) && (((oint)((object)( ((oint)(tint)(     0x0D  ) << 24 ) + (oint)(aint)(0) ))  &  0xFFFFFFFFUL  ) == 0) ? (void*)(subr_self) : (void*) ((void*)(((aint)((oint)(subr_self) >> 0 ) & (0x00FFFFFFUL  >> 0 )) ))  ) )) ->name), STACK  -=  -1) ;
  170.       fehler(
  171.               1  ? "~: ~ ist kein Vektor." :
  172.               0  ? "~: ~ is not a vector" :
  173.              ""
  174.             );
  175.     }
  176.    static  uintL* get_fill_pointer (object obj);
  177.    static  uintL* get_fill_pointer(    
  178.        register  object obj)
  179.     {  
  180.       {   register  object obj_from_if_vectorp = (obj);    register  tint type_from_if_vectorp = ((tint)((oint)(obj_from_if_vectorp) >> 24 )) ; type_from_if_vectorp = type_from_if_vectorp & ~ (1L<<( 2  )) ; if (!(type_from_if_vectorp==0)&&(type_from_if_vectorp<=   0x07  ))  ;  else  { fehler_vector(obj); } } ;
  181.       {   register  object obj_from_if_simplep = (obj);    register  tint type_from_if_simplep = ((tint)((oint)(obj_from_if_simplep) >> 24 )) ; if (!(type_from_if_simplep==0)&&(type_from_if_simplep<=  0x03  ))  { goto fehler_fillp; }  else  ;  } ;
  182.       if (!( ((Array)(((0 ==0) && (((oint)((object)( ((oint)(tint)(    0x04  ) << 24 ) + (oint)(aint)(0) ))  &  0xFFFFFFFFUL  ) == 0) ? (void*)(obj) : (void*) ((void*)(((aint)((oint)(obj) >> 0 ) & (0x00FFFFFFUL  >> 0 )) ))  ) )) ->flags &  (1L<<(      6 )) )) { goto fehler_fillp; }
  183.       return (( ((Array)(((0 ==0) && (((oint)((object)( ((oint)(tint)(    0x04  ) << 24 ) + (oint)(aint)(0) ))  &  0xFFFFFFFFUL  ) == 0) ? (void*)(obj) : (void*) ((void*)(((aint)((oint)(obj) >> 0 ) & (0x00FFFFFFUL  >> 0 )) ))  ) )) ->flags &  (1L<<( 4 )) )
  184.               ? & ((Array)(((0 ==0) && (((oint)((object)( ((oint)(tint)(    0x04  ) << 24 ) + (oint)(aint)(0) ))  &  0xFFFFFFFFUL  ) == 0) ? (void*)(obj) : (void*) ((void*)(((aint)((oint)(obj) >> 0 ) & (0x00FFFFFFUL  >> 0 )) ))  ) )) ->dims[2]  
  185.               : & ((Array)(((0 ==0) && (((oint)((object)( ((oint)(tint)(    0x04  ) << 24 ) + (oint)(aint)(0) ))  &  0xFFFFFFFFUL  ) == 0) ? (void*)(obj) : (void*) ((void*)(((aint)((oint)(obj) >> 0 ) & (0x00FFFFFFUL  >> 0 )) ))  ) )) ->dims[1]  
  186.              );
  187.       fehler_fillp:
  188.          ( (STACK[-1-(-1)])  = (obj), STACK  -=  -1) ;  ( (STACK[-1-(-1)])  = ( ((Subr)(((0 ==0) && (((oint)((object)( ((oint)(tint)(     0x0D  ) << 24 ) + (oint)(aint)(0) ))  &  0xFFFFFFFFUL  ) == 0) ? (void*)(subr_self) : (void*) ((void*)(((aint)((oint)(subr_self) >> 0 ) & (0x00FFFFFFUL  >> 0 )) ))  ) )) ->name), STACK  -=  -1) ;
  189.         fehler(
  190.                 1  ? "~: Vektor ~ hat keinen Fill-Pointer." :
  191.                 0  ? "~: vector ~ has no fill pointer" :
  192.                ""
  193.               );
  194.     }
  195. ============== array.s compiled with -O ========================================
  196.     .file    "array.i"
  197. gcc2_compiled.:
  198. .text
  199. LC0:
  200.     .ascii "~: ~ ist kein Vektor.\0"
  201.     .align 2
  202. _fehler_vector:
  203.     pushl %ebp
  204.     movl %esp,%ebp
  205.     movl _STACK,%eax
  206.     movl 8(%ebp),%ecx
  207.     movl %ecx,(%eax)
  208.     movl _STACK,%edx
  209.     addl $4,%edx
  210.     movl %edx,_STACK
  211.     movl _subr_self,%eax
  212.     andl $16777215,%eax
  213.     movl 4(%eax),%eax
  214.     movl %eax,(%edx)
  215.     addl $4,_STACK
  216.     pushl $LC0
  217.     call _fehler
  218.     .align 2,0x90
  219. LC1:
  220.     .ascii "~: Vektor ~ hat keinen Fill-Pointer.\0"
  221.     .align 2
  222. _get_fill_pointer:
  223.     pushl %ebp
  224.     movl %esp,%ebp
  225.     movl 8(%ebp),%ecx
  226.     movl %ecx,%eax
  227.     shrl $24,%eax
  228.     andb $251,%al
  229.     je L3
  230.     cmpb $7,%al
  231.     jbe L4
  232. L3:
  233.     pushl %ecx
  234.     call _fehler_vector
  235.     .align 2,0x90
  236. L4:
  237.     movl %ecx,%eax
  238.     shrl $24,%eax
  239.     testb %al,%al
  240.     je L7
  241.     cmpb $3,%al
  242.     jbe L6
  243. L7:
  244.     movl %ecx,%edx
  245.     andl $16777215,%edx
  246.     movb 4(%edx),%al
  247.     andb $64,%al
  248.     je L6
  249.     movb 4(%edx),%al
  250.     andb $16,%al
  251.     je L9
  252.     leal 28(%edx),%eax
  253.     leave
  254.     ret
  255.     .align 2,0x90
  256. L9:
  257.     movl %ecx,%eax
  258.     andl $16777215,%eax
  259.     addl $24,%eax
  260.     leave
  261.     ret
  262.     .align 2,0x90
  263. L6:
  264.     movl _STACK,%eax
  265.     movl %ecx,(%eax)
  266.     movl _STACK,%edx
  267.     addl $4,%edx
  268.     movl %edx,_STACK
  269.     movl _subr_self,%eax
  270.     andl $16777215,%eax
  271.     movl 4(%eax),%eax
  272.     movl %eax,(%edx)
  273.     addl $4,_STACK
  274.     pushl $LC1
  275.     call _fehler
  276.     .align 2,0x90
  277. ============= array.s compiled with -O2 ========================================
  278.     .file    "array.i"
  279. gcc2_compiled.:
  280. .text
  281. LC0:
  282.     .ascii "~: ~ ist kein Vektor.\0"
  283.     .align 2
  284. _fehler_vector:
  285.     pushl %ebp
  286.     movl %esp,%ebp
  287.     movl _STACK,%eax
  288.     movl 8(%ebp),%ecx
  289.     movl %ecx,(%eax)
  290.     movl _STACK,%edx
  291.     addl $4,%edx
  292.     movl %edx,_STACK
  293.     movl _subr_self,%eax
  294.     andl $16777215,%eax
  295.     movl 4(%eax),%eax
  296.     movl %eax,(%edx)
  297.     addl $4,_STACK
  298.     pushl $LC0
  299.     call _fehler
  300.     .align 2,0x90
  301. LC1:
  302.     .ascii "~: Vektor ~ hat keinen Fill-Pointer.\0"
  303.     .align 2
  304. _get_fill_pointer:
  305.     pushl %ebp
  306.     movl %esp,%ebp
  307.     movl 8(%ebp),%ecx
  308.     movl %ecx,%edx
  309.     shrl $24,%edx
  310.     testb $251,%dl
  311.     je L3
  312.     cmpb $7,%al                ; INCORRECT
  313.     jbe L4
  314. L3:
  315.     pushl %ecx
  316.     call _fehler_vector
  317.     .align 2,0x90
  318. L4:
  319.     movb %dl,%al
  320.     testb %al,%al
  321.     je L7
  322.     cmpb $3,%al
  323.     jbe L6
  324. L7:
  325.     movl %ecx,%edx
  326.     andl $16777215,%edx
  327.     movb 4(%edx),%al
  328.     andb $64,%al
  329.     je L6
  330.     movb 4(%edx),%al
  331.     andb $16,%al
  332.     je L9
  333.     leal 28(%edx),%eax
  334.     leave
  335.     ret
  336.     .align 2,0x90
  337. L9:
  338.     leal 24(%edx),%eax
  339.     leave
  340.     ret
  341.     .align 2,0x90
  342. L6:
  343.     movl _STACK,%eax
  344.     movl %ecx,(%eax)
  345.     movl _STACK,%edx
  346.     addl $4,%edx
  347.     movl %edx,_STACK
  348.     movl _subr_self,%eax
  349.     andl $16777215,%eax
  350.     movl 4(%eax),%eax
  351.     movl %eax,(%edx)
  352.     addl $4,_STACK
  353.     pushl $LC1
  354.     call _fehler
  355.     .align 2,0x90
  356. ================================================================================
  357.  
  358. Bruno Haible
  359. haible@ma2s2.mathematik.uni-karlsruhe.de
  360.  
  361.  
  362.