On 04/07/2017 01:36 AM, Uros Bizjak wrote:
Hello!

Attached patch mitigates:

FAIL: gcc.dg/unroll-7.c scan-rtl-dump loop2_unroll "number of
iterations: .const_int 999999"

testsuite failure for x32 target. Loop analysis determines:

Loop 1 is simple:
  simple exit 3 -> 4
  infinite if: (expr_list:REG_DEP_TRUE (ne:SI (and:SI (minus:SI
(reg:SI 106 [ _13 ])
                (reg:SI 105 [ ivtmp.10 ]))
            (const_int 3 [0x3]))
        (const_int 0 [0]))
    (nil))
  number of iterations: (lshiftrt:SI (plus:SI (minus:SI (reg:SI 106 [ _13 ])
            (reg:SI 105 [ ivtmp.10 ]))
        (const_int -4 [0xfffffffffffffffc]))
    (const_int 2 [0x2]))
  upper bound: 999999
  likely upper bound: 999999
  realistic bound: 999999

but it doesn't figure out that with (reg 105) and (reg 106), defined as:

(insn 22 19 23 2 (set (reg:SI 105 [ ivtmp.10 ])
        (subreg/s/v:SI (reg/v/f:DI 110 [ a ]) 0)) 82 {*movsi_internal}
     (nil))
(insn 23 22 28 2 (parallel [
            (set (reg:SI 106 [ _13 ])
                (plus:SI (subreg/s/v:SI (reg/v/f:DI 110 [ a ]) 0)
                    (const_int 4000000 [0x3d0900])))
            (clobber (reg:CC 17 flags))
        ]) 217 {*addsi_1}

(minus:SI (reg:SI 106) ( reg:SI 105)) evaluates to (const_int
4000000). Probably, because subregs are involved.

Short of enhancing loop analysis to properly handle subregs, I propose
following testsuite patch that avoids particularities of argument
passing.

2017-04-07  Uros Bizjak  <ubiz...@gmail.com>

    * gcc.dg/unroll-7.c: Declare "a" as pointer to external array.
OK.

Jeff

Reply via email to