This is the mail archive of the gcc@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]
Other format: [Raw text]

[new regalloc]: Miscompile for s390x


Hello,
      while running regtest for S390x on the regalloc branch, found that
c-format.c is miscompiled.
Boiled it down to following:

c code fragment:

      format_wanted_type main_wanted_type;
      format_wanted_type *first_wanted_type = ((void *)0);
....
      while (1)
       {
....
          if (first_wanted_type == 0)
            first_wanted_type = &main_wanted_type;

          if (first_wanted_type != 0)
            check_format_types (status, first_wanted_type);
       }

compiled with -O2

Code sequence in cf.i.20.sched:

(insn 104 93 123 (set (reg/v/f:DI 78)
        (const_int 0 [0x0])) 47 {*movdi_lhi} (nil)
    (expr_list:REG_EQUAL (const_int 0 [0x0])
        (nil)))

....

(note 4703 4140 4142 [bb 348] NOTE_INSN_BASIC_BLOCK)

(insn:QI 4142 4703 4143 (set (reg:CCZ 33 %cc)
        (compare:CCZ (reg/v/f:DI 78)
            (const_int 0 [0x0]))) 4 {*cmpdi_ccs_0_64} (nil)
    (nil))

(jump_insn 4143 4142 4704 (set (pc)
        (if_then_else (ne (reg:CCZ 33 %cc)
                (const_int 0 [0x0]))
            (label_ref 5311)
            (pc))) 243 {cjump} (insn_list 4142 (nil))
    (expr_list:REG_DEAD (reg:CCZ 33 %cc)
        (expr_list:REG_BR_PROB (const_int 8100 [0x1fa4])
            (nil))))
;; End of basic block 348, registers live:
 11 [%r11] 15 [%r15] 32 [%ap] 34 [%fp] 40 41 42 45 50 51 52 53 60 61 62 78 187

;; Start of basic block 349, registers live: 11 [%r11] 15 [%r15] 32 [%ap] 34 [%fp] 40 41 42 45 50 51 52 53 60 61 62 187
(note 4704 4143 4146 [bb 349] NOTE_INSN_BASIC_BLOCK)

(insn 4146 4704 4151 (parallel[
            (set (reg/v/f:DI 78)
                (plus:DI (reg/f:DI 34 %fp)
                    (const_int 296 [0x128])))
            (clobber (reg:CC 33 %cc))
        ] ) 114 {adddi3_64} (nil)
    (expr_list:REG_UNUSED (reg:CC 33 %cc)
        (nil)))
;; End of basic block 349, registers live:
 11 [%r11] 15 [%r15] 32 [%ap] 34 [%fp] 40 41 42 45 50 51 52 53 60 61 62 78 187

;; Start of basic block 350, registers live: 11 [%r11] 15 [%r15] 32 [%ap] 34 [%fp] 40 41 42 45 50 51 52 53 60 61 62 78 187
(code_label 4151 4146 4706 280 "" "" [3 uses])

(note 4706 4151 4153 [bb 350] NOTE_INSN_BASIC_BLOCK)

(insn:QI 4153 4706 4154 (set (reg:CCZ 33 %cc)
        (compare:CCZ (reg/v/f:DI 78)
            (const_int 0 [0x0]))) 4 {*cmpdi_ccs_0_64} (nil)
    (nil))

(jump_insn 4154 4153 5311 (set (pc)
        (if_then_else (eq (reg:CCZ 33 %cc)
                (const_int 0 [0x0]))
            (label_ref 4164)
            (pc))) 243 {cjump} (insn_list 4153 (nil))
    (expr_list:REG_DEAD (reg:CCZ 33 %cc)
        (expr_list:REG_BR_PROB (const_int 10000 [0x2710])
            (nil))))
;; End of basic block 350, registers live:
 11 [%r11] 15 [%r15] 32 [%ap] 34 [%fp] 40 41 42 45 50 51 52 53 60 61 62 78 187


Code sequence in cf.i.21.lreg:


  104 p78 <= 0
   --> matched alternative 0
      op0: =d           p78
      op1: K            0

  ....

  4142      %cc <= (p78 ? 0)
   --> matched alternative 0
      op0: d            p78
      op1:        0
  4143      if (%cc != 0) jump L318
   --> has no constrained operands, i.e. is valid
  4146      p78 <= (%fp + 296)      ;; %cc <= clobber
   --> matched alternative 0
      op0: =d           p78
      op1: %0           %fp
      op2: d            296
  4153      %cc <= (p78 ? 0)
   --> matched alternative 0
      op0: d            p78
      op1:        0
  4154      if (%cc == 0) jump L295
   --> has no constrained operands, i.e. is valid

...

RegAlloc Pass 0:
...
                              ; 104 NOTE_INSN_DELETED

....

L292: ;  [1 uses] uid=(4140)
  5414      p78 <= 0
  4142      %cc <= (p78 ? 0)
  4143      if (%cc != 0) jump L318
;; End of basic block 348
;; Begin of basic block 349
                              ; 4146 NOTE_INSN_DELETED
;; End of basic block 349
;; Begin of basic block 350

L280: ;  [3 uses] uid=(4151)
  5412      p78 <= 0                        <- Look like wrong rematerializations
  4153      %cc <= (p78 ? 0)
  4154      if (%cc == 0) jump L295

I haven't found the specific problem in ra.c not yet.

c-format fragment to compile:

(See attached file: cf.i)


Mit freundlichem Gruß / Best regards,

Hartmut Penner
GCC for S/390 Development

Internet Mail Address : hpenner@de.ibm.com

Tel: (49)-7031-16-4364

Attachment: =?iso-8859-1?Q?cf.i?=
Description: Binary data


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