This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: optimization bug


Hi,

The problem shows up on an alpha-dec-osf4.0 with haifa schedule.
I have not compile the program without haifa schedule, so I do not known
if what I say below will apply.

The RTL files t1.c.sched and t1.c.lreg are in the appendix.

Note the INSN in t1.c.sched
======>(insn 88 4 15 (use (reg:DI 88)) -1 (nil)
is changed in t1.c.lreg to 
======>(insn 88 4 15 (use (const:DI (plus:DI (symbol_ref:DI ("pure"))
which should not have happened.

With this change, pseudo-reg 88 is never set, but it is used later which
cause the program crash.

The patch I sent in will disable this change.

Weiwen

Appendix:
With haifa schedule, the RTL files after schedule is
/* t1.c.sched */
;; Function purified

(note 2 0 5 "" NOTE_INSN_DELETED)

;; Start of basic block 0, registers live: 16 [$16] 86 88
(note 5 2 6 "" NOTE_INSN_FUNCTION_BEG)

(note 6 5 8 "" NOTE_INSN_DELETED)

(note 8 6 11 "" NOTE_INSN_DELETED)

(note 11 8 12 "" NOTE_INSN_DELETED)

(note 12 11 17 "" NOTE_INSN_DELETED)

(note 17 12 25 "" NOTE_INSN_DELETED)

(note 25 17 4 "" NOTE_INSN_DELETED)

(insn 4 25 88 (set (reg/v:DI 68)
        (reg:DI 16 $16)) 254 {movdi-1} (nil)
    (expr_list:REG_DEAD (reg:DI 16 $16)
        (nil)))

(insn 88 4 15 (use (reg:DI 88)) -1 (nil)
    (expr_list:REG_DEAD (reg:DI 88)
        (nil)))

(insn 15 88 87 (set (reg:DI 74)
        (and:DI (reg/v:DI 68)
            (const_int 7))) 41 {anddi3} (insn_list 4 (nil))
    (nil))

(insn 87 15 22 (use (reg:DI 86)) -1 (nil)
    (expr_list:REG_DEAD (reg:DI 86)
        (nil)))

(insn 22 87 39 (set (reg:DI 78)
        (eq:DI (reg:DI 74)
            (const_int 6))) 131 {subdf3+4} (insn_list 15 (nil))
    (nil))

(insn 39 22 26 (set (reg:DI 84)
        (lshiftrt:DI (reg/v:DI 68)
            (const_int 4))) 64 {lshrdi3} (insn_list 4 (nil))
    (expr_list:REG_DEAD (reg/v:DI 68)
        (nil)))

(insn 26 39 44 (set (reg:DI 80)
        (if_then_else:DI (ne (reg:DI 74)
                (const_int 0))
            (reg:DI 78)
            (const_int 1))) 134 {absdi2-6} (insn_list 15 (insn_list 22 (nil)))
    (expr_list:REG_DEAD (reg:DI 74)
        (expr_list:REG_DEAD (reg:DI 78)
            (nil))))

(insn 44 26 45 (set (reg:DI 85)
        (symbol_ref:DI ("pure"))) 254 {movdi-1} (nil)
    (nil))

(insn 45 44 28 (set (reg:DI 88)
        (const:DI (plus:DI (symbol_ref:DI ("pure"))
                (const_int 1788000)))) 254 {movdi-1} (insn_list:REG_DEP_ANTI 88 (nil))
    (expr_list:REG_EQUAL (const:DI (plus:DI (symbol_ref:DI ("pure"))
                (const_int 1788000)))
        (nil)))

(jump_insn 28 45 31 (set (pc)
        (if_then_else (eq (reg:DI 80)
                (const_int 0))
            (label_ref 35)
            (pc))) 157 {umindi3+2} (insn_list:REG_DEP_ANTI 4 (insn_list:REG_DEP_ANTI 15 (insn_list:REG_DEP_ANTI 22 (insn_list 26 (nil)))))
    (expr_list:REG_DEAD (reg:DI 80)
        (nil)))
;; End of basic block 0

;; Start of basic block 1, registers live:
(insn 31 28 33 (set (reg/i:DI 0 $0)
        (const_int 0)) 254 {movdi-1} (nil)
    (expr_list:REG_EQUAL (const_int 0)
        (nil)))

(jump_insn 33 31 34 (set (pc)
        (label_ref 65)) 230 {jump} (insn_list:REG_DEP_ANTI 31 (nil))
    (nil))
;; End of basic block 1

(barrier 34 33 35)

;; Start of basic block 2, registers live: 84 85 88
(code_label 35 34 38 2 "")

(note 38 35 41 "" NOTE_INSN_DELETED)

(note 41 38 43 "" NOTE_INSN_DELETED)

(note 43 41 82 "" NOTE_INSN_DELETED)

(note 82 43 84 "" NOTE_INSN_DELETED)

(note 84 82 76 "" NOTE_INSN_DELETED)

(note 76 84 79 "" NOTE_INSN_DELETED)

(note 79 76 80 "" NOTE_INSN_DELETED)

(note 80 79 77 "" NOTE_INSN_DELETED)

(insn 77 80 46 (set (reg:DI 96)
        (leu:DI (reg:DI 85)
            (reg:DI 84))) 131 {subdf3+4} (insn_list 39 (insn_list 44 (nil)))
    (expr_list:REG_DEAD (reg:DI 85)
        (nil)))

(insn 46 77 56 (set (reg:DI 89)
        (ltu:DI (reg:DI 84)
            (reg:DI 88))) 131 {subdf3+4} (insn_list 39 (insn_list 45 (nil)))
    (expr_list:REG_DEAD (reg:DI 84)
        (expr_list:REG_DEAD (reg:DI 88)
            (nil))))

(insn 56 46 65 (set (reg/i:DI 0 $0)
        (if_then_else:DI (ne (reg:DI 89)
                (const_int 0))
            (subreg:DI (reg:DI 96) 0)
            (const_int 0))) 134 {absdi2-6} (insn_list 46 (insn_list 77 (nil)))
    (expr_list:REG_DEAD (reg:DI 89)
        (expr_list:REG_DEAD (reg:DI 96)
            (nil))))
;; End of basic block 2

;; Start of basic block 3, registers live: 0 [$0]
(code_label 65 56 64 4 "")

(insn 64 65 89 (use (reg/i:DI 0 $0)) -1 (insn_list 56 (insn_list 31 (nil)))
    (expr_list:REG_DEAD (reg/i:DI 0 $0)
        (nil)))
;; End of basic block 3

(note 89 64 0 "" NOTE_INSN_DELETED)
======END

RTL file after local register allocation:
/* t1.c.lreg */
;; Function purified

100 registers.

Register 68 used 3 times across 6 insns in block 0; GENERAL_REGS or none.

Register 74 used 3 times across 5 insns in block 0; GENERAL_REGS or none.

Register 78 used 2 times across 3 insns in block 0; GENERAL_REGS or none.

Register 80 used 2 times across 4 insns in block 0; GENERAL_REGS or none.

Register 84 used 3 times across 7 insns; GENERAL_REGS or none.

Register 85 used 3 times across 4 insns; GENERAL_REGS or none; pointer.

Register 89 used 2 times across 2 insns in block 2; GENERAL_REGS or none.

Register 96 used 2 times across 3 insns in block 2; GENERAL_REGS or none.

4 basic blocks.

Basic block 0: first insn 5, last 28.

Registers live at start: 16 86 88

Basic block 1: first insn 31, last 33.

Registers live at start:

Basic block 2: first insn 35, last 56.

Registers live at start: 84 85 88

Basic block 3: first insn 65, last 64.

Registers live at start: 0

;; Register 68 in 16.
;; Register 74 in 2.
;; Register 78 in 1.
;; Register 80 in 1.
;; Register 89 in 1.
;; Register 96 in 0.
(note 2 0 5 "" NOTE_INSN_DELETED)

;; Start of basic block 0, registers live: 16 [$16] 86 88
(note 5 2 6 "" NOTE_INSN_FUNCTION_BEG)

(note 6 5 8 "" NOTE_INSN_DELETED)

(note 8 6 11 "" NOTE_INSN_DELETED)

(note 11 8 12 "" NOTE_INSN_DELETED)

(note 12 11 17 "" NOTE_INSN_DELETED)

(note 17 12 25 "" NOTE_INSN_DELETED)

(note 25 17 4 "" NOTE_INSN_DELETED)

(insn 4 25 88 (set (reg/v:DI 68)
        (reg:DI 16 $16)) 254 {movdi-1} (nil)
    (expr_list:REG_DEAD (reg:DI 16 $16)
        (nil)))

(insn 88 4 15 (use (const:DI (plus:DI (symbol_ref:DI ("pure"))
                (const_int 1788000)))) -1 (nil)
    (nil))

(insn 15 88 87 (set (reg:DI 74)
        (and:DI (reg/v:DI 68)
            (const_int 7))) 41 {anddi3} (insn_list 4 (nil))
    (nil))

(insn 87 15 22 (use (reg:DI 86)) -1 (nil)
    (expr_list:REG_DEAD (reg:DI 86)
        (nil)))

(insn 22 87 39 (set (reg:DI 78)
        (eq:DI (reg:DI 74)
            (const_int 6))) 131 {subdf3+4} (insn_list 15 (nil))
    (nil))

(insn 39 22 26 (set (reg:DI 84)
        (lshiftrt:DI (reg/v:DI 68)
            (const_int 4))) 64 {lshrdi3} (insn_list 4 (nil))
    (expr_list:REG_DEAD (reg/v:DI 68)
        (nil)))

(insn 26 39 44 (set (reg:DI 80)
        (if_then_else:DI (ne (reg:DI 74)
                (const_int 0))
            (reg:DI 78)
            (const_int 1))) 134 {absdi2-6} (insn_list 15 (insn_list 22 (nil)))
    (expr_list:REG_DEAD (reg:DI 74)
        (expr_list:REG_DEAD (reg:DI 78)
            (nil))))

(insn 44 26 45 (set (reg:DI 85)
        (symbol_ref:DI ("pure"))) 254 {movdi-1} (nil)
    (nil))

(note 45 44 28 "" NOTE_INSN_DELETED)

(jump_insn 28 45 31 (set (pc)
        (if_then_else (eq (reg:DI 80)
                (const_int 0))
            (label_ref 35)
            (pc))) 157 {umindi3+2} (insn_list:REG_DEP_ANTI 4 (insn_list:REG_DEP_ANTI 15 (insn_list:REG_DEP_ANTI 22 (insn_list 26 (nil)))))
    (expr_list:REG_DEAD (reg:DI 80)
        (nil)))
;; End of basic block 0

;; Start of basic block 1, registers live:
(insn 31 28 33 (set (reg/i:DI 0 $0)
        (const_int 0)) 254 {movdi-1} (nil)
    (expr_list:REG_EQUAL (const_int 0)
        (nil)))

(jump_insn 33 31 34 (set (pc)
        (label_ref 65)) 230 {jump} (insn_list:REG_DEP_ANTI 31 (nil))
    (nil))
;; End of basic block 1

(barrier 34 33 35)

;; Start of basic block 2, registers live: 84 85 88
(code_label 35 34 38 2 "")

(note 38 35 41 "" NOTE_INSN_DELETED)

(note 41 38 43 "" NOTE_INSN_DELETED)

(note 43 41 82 "" NOTE_INSN_DELETED)

(note 82 43 84 "" NOTE_INSN_DELETED)

(note 84 82 76 "" NOTE_INSN_DELETED)

(note 76 84 79 "" NOTE_INSN_DELETED)

(note 79 76 80 "" NOTE_INSN_DELETED)

(note 80 79 77 "" NOTE_INSN_DELETED)

(insn 77 80 46 (set (reg:DI 96)
        (leu:DI (reg:DI 85)
            (reg:DI 84))) 131 {subdf3+4} (insn_list 39 (insn_list 44 (nil)))
    (expr_list:REG_DEAD (reg:DI 85)
        (nil)))

(insn 46 77 56 (set (reg:DI 89)
        (ltu:DI (reg:DI 84)
            (reg:DI 88))) 131 {subdf3+4} (insn_list 39 (insn_list 45 (nil)))
    (expr_list:REG_DEAD (reg:DI 84)
        (expr_list:REG_DEAD (reg:DI 88)
            (nil))))

(insn 56 46 65 (set (reg/i:DI 0 $0)
        (if_then_else:DI (ne (reg:DI 89)
                (const_int 0))
            (subreg:DI (reg:DI 96) 0)
            (const_int 0))) 134 {absdi2-6} (insn_list 46 (insn_list 77 (nil)))
    (expr_list:REG_DEAD (reg:DI 89)
        (expr_list:REG_DEAD (reg:DI 96)
            (nil))))
;; End of basic block 2

;; Start of basic block 3, registers live: 0 [$0]
(code_label 65 56 64 4 "")

(insn 64 65 89 (use (reg/i:DI 0 $0)) -1 (insn_list 56 (insn_list 31 (nil)))
    (expr_list:REG_DEAD (reg/i:DI 0 $0)
        (nil)))
;; End of basic block 3

(note 89 64 0 "" NOTE_INSN_DELETED)
======END



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]