https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83327

            Bug ID: 83327
           Summary: Spilling into hard regs not taken into account in lra
                    liveness analysis
           Product: gcc
           Version: 7.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

This is a problem I'm running into with a gcn port on top of 7.1.0 on an
internal branch. [ This may be a duplicate of PR71657 - Wrong code on trunk gcc
(std::out_of_range), westmere . ]

The symptom is an execution failure when running no-scevccp-outer-10.c.

The port has the TARGET_SPILL_CLASS hook enabled, which enables spilling into
hard  regs.


I. 

At ira, we have a def and use of 'reg:BI 605', the def in bb2 and the use in
bb3:
...
(note 44 32 33 2 [bb 2] NOTE_INSN_BASIC_BLOCK)

   ...

(insn 269 54 64 2 (set (reg:BI 605)
        (le:BI (reg/v:SI 491 [ n ])
            (const_int 0 [0]))) 23 {cstoresi4}
     (nil))

   ....

(code_label 250 228 56 3 7 (nil) [1 uses])
(note 56 250 58 3 [bb 3] NOTE_INSN_BASIC_BLOCK)

   ...

(jump_insn 62 60 63 3 (set (pc)
        (if_then_else (ne:BI (reg:BI 605)
                (const_int 0 [0]))
            (label_ref 242)
            (pc))) "no-scevccp-outer-10.c":19 21 {cjump}
     (int_list:REG_BR_PROB 1500 (nil))
 -> 242)
(note 63 62 66 4 [bb 4] NOTE_INSN_BASIC_BLOCK)
...

And in lra, we decide to spill it into a hard register:
...
  Spill r605 into hr95
...

Resulting in this code:
...
(insn 385 386 64 2 (set (reg:BI 95 s95)
        (reg:BI 18 s18 [605])) 3 {*movbi}
     (nil))

  ...

(insn 404 60 405 3 (set (reg:BI 18 s18 [605])
        (reg:BI 95 s95)) "no-scevccp-outer-10.c":19 3 {*movbi}
     (nil))
...


II.

However, a bit later in lra we decide to assign r94,r95 to DImode pseudo 833:
...
           Assign 94 to reload r833 (freq=60)
...

Resulting in this code:
...
(insn 629 378 390 2 (set (reg:DI 94 s94 [833])
        (plus:DI (reg/f:DI 16 s16)
            (const_int -8 [0xfffffffffffffff8]))) 35 {addptrdi3}
     (nil))
...

This clobbers the def of s95 in insn 385.


III.

Consequently, the insn is removed in the dce in the jump pass:
...
DCE: Deleting insn 385
deleting insn with uid = 385.
...

Reply via email to