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 loop unroller broken?


Hello,

the new loop unroller doesn't unroll the following trivial loop
on s390 (with -O2 -funroll-loops):

void test(float *data, float d) 
{
   int i;
   for (i = 0; i < 8; i++)
      data[i] = d;
}

because of
'Unable to prove that the loop iterates constant times'
which strikes me as somewhat odd.

Is this the same on other platforms?  Any ideas how to fix
this (or how to debug it)?

Attached is the test.c.16.loop2 file.

(B.t.w. -fold-unroll-loops unrolls this loop just fine.)

Bye,
Ulrich



;; Function test

50 registers.

Register 40 used 1 times across 0 insns; set 1 time; user var; dies in 0 places; pointer.

Register 41 used 1 times across 0 insns; set 1 time; user var; dies in 0 places.

Register 42 used 3 times across 0 insns; set 3 times; user var; dies in 0 places.

Register 47 used 2 times across 0 insns; set 2 times; dies in 0 places; pointer.

Register 49 used 2 times across 0 insns; set 2 times; dies in 0 places.

2 basic blocks, 4 edges.

Basic block 0: first insn 37, last 82, prev -1, next 1, loop_depth 0, count 0, freq 1250, maybe hot.
Predecessors:  ENTRY [100.0%]  (fallthru)
Successors:  1 [100.0%]  (fallthru)
Registers live at start: (nil)
Registers live at end: (nil)

Basic block 1: first insn 81, last 80, prev 0, next -2, loop_depth 1, count 0, freq 10000, maybe hot.
Predecessors:  1 [87.5%]  (dfs_back) 0 [100.0%]  (fallthru)
Successors:  EXIT [12.5%]  (fallthru,loop_exit) 1 [87.5%]  (dfs_back)
Registers live at start: (nil)
Registers live at end: (nil)



try_optimize_cfg iteration 1

Fallthru edge 1->2 redirected to 2
Edge 1->1 redirected to 3
;; 2 loops found, 2 levels
;;
;; Loop 0:
;;  header -1, latch -2, pre-header -1
;;  depth 0, level 2, outer -1
;;  nodes: -1 0 1 3 2 -2
;;
;; Loop 1:
;;  header 1, latch 3, pre-header -1
;;  depth 1, level 1, outer 0
;;  nodes: 1 3
;; 0 succs { 1 }
;; 1 succs { 2 3 }
;; 3 succs { 1 }
;; 2 succs { -2 }
;; Considering loop 1 for complete peeling
;; Considering peeling once rolling loop
;; Unable to prove that the loop rolls exactly once
;; Considering peeling completely
;; Unable to prove that the loop iterates constant times
;; Considering loop 1
;; Considering unrolling loop with constant number of iterations
;; Unable to prove that the loop iterates constant times
;; Considering unrolling loop with runtime computable number of iterations
;; Unable to prove that the number of iterations can be counted in runtime
;; 2 loops found, 2 levels
;;
;; Loop 0:
;;  header -1, latch -2, pre-header -1
;;  depth 0, level 2, outer -1
;;  nodes: -1 0 1 3 2 -2
;;
;; Loop 1:
;;  header 1, latch 3, pre-header -1
;;  depth 1, level 1, outer 0
;;  nodes: 1 3
;; 0 succs { 1 }
;; 1 succs { 2 3 }
;; 3 succs { 1 }
;; 2 succs { -2 }
Emitting label for block 2
Reordered sequence:
 0 bb 0  [1250]
 1 bb 1  [10000]
 2 compensation  [1250]
 3 bb 3  [8750]
 4 bb 2  [1250]


try_optimize_cfg iteration 1

Forwarding edge 1->2 to 4 failed.
Edge 1->3 redirected to 1
Forwarding edge 1->2 to 4 failed.
Deleting block 3.
Removing jump 88.
Deleting fallthru block 2.
Deleted label in block 4.
Deleting fallthru block 4.


try_optimize_cfg iteration 2

50 registers.

Register 40 used 1 times across 0 insns; set 1 time; user var; dies in 0 places; pointer.

Register 41 used 1 times across 0 insns; set 1 time; user var; dies in 0 places.

Register 42 used 3 times across 0 insns; set 3 times; user var; dies in 0 places.

Register 47 used 2 times across 0 insns; set 2 times; dies in 0 places; pointer.

Register 49 used 2 times across 0 insns; set 2 times; dies in 0 places.

2 basic blocks, 4 edges.

Basic block 0: first insn 37, last 82, prev -1, next 1, loop_depth 0, count 0, freq 1250, maybe hot.
Predecessors:  ENTRY [100.0%]  (fallthru)
Successors:  1 [100.0%]  (fallthru)
Registers live at start: (nil)
Registers live at end: (nil)

Basic block 1: first insn 81, last 80, prev 0, next -2, loop_depth 1, count 0, freq 10000, maybe hot.
Predecessors:  1 [87.5%]  (dfs_back) 0 [100.0%]  (fallthru)
Successors:  EXIT [12.5%]  (fallthru) 1 [87.5%]  (dfs_back)
Registers live at start: (nil)
Registers live at end: (nil)

(note 2 0 37 NOTE_INSN_DELETED)

;; Start of basic block 0, registers live: (nil)
(note 37 2 3 0 [bb 0] NOTE_INSN_BASIC_BLOCK)

(insn 3 37 4 0 (set (reg/v/f:SI 40 [ data ])
        (reg:SI 2 %r2 [ data ])) 54 {*movsi_esa} (nil)
    (nil))

(insn 4 3 5 0 (set (reg/v:SF 41 [ d ])
        (reg:SF 16 %f0 [ d ])) 62 {*movsf} (nil)
    (nil))

(note 5 4 11 0 NOTE_INSN_FUNCTION_BEG)

(insn 11 5 44 0 (set (reg/v:SI 42 [ i ])
        (const_int 0 [0x0])) 54 {*movsi_esa} (nil)
    (nil))

(insn 44 11 74 0 (set (reg:CCS 33 %cc)
        (compare:CCS (reg/v:SI 42 [ i ])
            (const_int 7 [0x7]))) 29 {*cmpsi_ccs} (nil)
    (expr_list:REG_EQUAL (compare:CCS (const_int 0 [0x0])
            (const_int 7 [0x7]))
        (nil)))

(insn 74 44 75 0 (set (reg/f:SI 47 [ data ])
        (reg/v/f:SI 40 [ data ])) -1 (nil)
    (nil))

(insn 75 74 82 0 (set (reg/v:SI 42 [ i ])
        (const_int 7 [0x7])) -1 (nil)
    (nil))

(insn 82 75 12 0 (set (reg:SI 49)
        (const_int 8 [0x8])) -1 (nil)
    (nil))
;; End of basic block 0, registers live:
 (nil)

(note 12 82 81 NOTE_INSN_LOOP_BEG)

;; Start of basic block 1, registers live: (nil)
(code_label 81 12 38 1 8 "" [1 uses])

(note 38 81 21 1 [bb 1] NOTE_INSN_BASIC_BLOCK)

(insn 21 38 23 1 (set (mem:SF (reg/f:SI 47 [ data ]) [4 S4 A32])
        (reg/v:SF 41 [ d ])) -1 (nil)
    (nil))

(note 23 21 76 1 NOTE_INSN_LOOP_CONT)

(insn 76 23 73 1 (parallel [
            (set (reg/v:SI 42 [ i ])
                (plus:SI (reg/v:SI 42 [ i ])
                    (const_int -1 [0xffffffffffffffff])))
            (clobber (reg:CC 33 %cc))
        ]) -1 (nil)
    (nil))

(insn 73 76 50 1 (parallel [
            (set (reg/f:SI 47 [ data ])
                (plus:SI (reg/f:SI 47 [ data ])
                    (const_int 4 [0x4])))
            (clobber (reg:CC 33 %cc))
        ]) -1 (nil)
    (nil))

(note 50 73 77 1 NOTE_INSN_LOOP_VTOP)

(insn 77 50 80 1 (set (reg:CCS 33 %cc)
        (compare:CCS (reg/v:SI 42 [ i ])
            (const_int 0 [0x0]))) -1 (nil)
    (nil))

(jump_insn 80 77 31 1 (parallel [
            (set (pc)
                (if_then_else (ne (reg:SI 49)
                        (const_int 1 [0x1]))
                    (label_ref 81)
                    (pc)))
            (set (reg:SI 49)
                (plus:SI (reg:SI 49)
                    (const_int -1 [0xffffffffffffffff])))
            (clobber (scratch:SI))
            (clobber (reg:CC 33 %cc))
        ]) 292 {doloop_si} (nil)
    (expr_list:REG_BR_PROB (const_int 8750 [0x222e])
        (nil)))
;; End of basic block 1, registers live:
 (nil)

(note 31 80 34 NOTE_INSN_LOOP_END)

(note 34 31 0 NOTE_INSN_FUNCTION_END)

-- 
  Dr. Ulrich Weigand
  weigand@informatik.uni-erlangen.de


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