A gcse bug

H.J. Lu hjl@lucon.org
Sat Jul 11 15:24:00 GMT 1998


> 
> 
> 
>   > > Can you provide a testcase?  I don't know the x86 well enough to be
>   > > able to debug the problem in any kind of reasonable timeframe.  Even
>   > > a large function is OK if you can point out the instructions which
>   > > are incorrectly optimized.
>   > > 
>   > > 
>   > 
>   > Here is a testcase for gcse bug. Compile it with -O2. You should
>   > get a core dump on x86.
> It works just fine for me on my x86.  I asked you to point out exactly
> what got mis-compiled, can you do that?  
> 

I will try. The current egcs in CVS as of 11:00am PDT on 980711 has the
same bug. The main function is miscompiled. Now I believe it is the
same alias bug I reported. Here is the greg RTL dump:


;; Start of basic block 63, registers live: 6 [bp] 7 [sp] 21 149 201 220 250 251
(code_label/i 767 766 768 1275 "")

(insn/i 768 767 769 (set (mem/s:SI (reg/v:SI 4 %esi))
        (reg:SI 0 %eax)) 54 {movsi+2} (nil)
    (expr_list:REG_DEAD (reg:SI 0 %eax)
        (expr_list:REG_DEAD (reg/v:SI 4 %esi)
            (nil))))
  
(note/i 769 768 771 0 NOTE_INSN_BLOCK_END)
  
(note 771 769 912 0 NOTE_INSN_BLOCK_END)
  
(note 912 771 602 "" NOTE_INSN_LOOP_VTOP)
  
(note/i 602 912 618 "" NOTE_INSN_DELETED)
  
(insn:HI 618 602 1027 (set (reg:SI 5 %edi)
        (mem:SI (plus:SI (reg:SI 6 %ebp)
                (const_int -60)))) 54 {movsi+2} (nil)
    (nil))
  

Here is the sched2 RTL dump

;; Start of basic block 63, registers live: 6 [bp] 7 [sp] 21 149 201 220 250 251
(code_label/i 767 766 769 1275 "")

(note/i 769 767 771 0 NOTE_INSN_BLOCK_END)                     
  
(note 771 769 912 0 NOTE_INSN_BLOCK_END)
  
(note 912 771 602 "" NOTE_INSN_LOOP_VTOP)
  
(note/i 602 912 924 "" NOTE_INSN_DELETED)                               
  
(note 924 602 618 "" NOTE_INSN_DELETED)
  
(insn:HI 618 924 768 (set (reg:SI 5 %edi)
        (mem:SI (plus:SI (reg:SI 6 %ebp)
                (const_int -60)))) 54 {movsi+2} (nil)                   
    (nil))
  
(insn/i 768 618 1027 (set (mem/s:SI (reg/v:SI 4 %esi))
        (reg:SI 0 %eax)) 54 {movsi+2} (nil)
    (expr_list:REG_DEAD (reg:SI 0 %eax)
        (expr_list:REG_DEAD (reg/v:SI 4 %esi)
            (nil))))

You can see insns 618 and 768 are swapped. But

(reg/v:SI 4 %esi) == (plus:SI (reg:SI 6 %ebp) (const_int -60))



H.J.



More information about the Gcc-bugs mailing list