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. Patch was tested on x86_64 {,-m32,-mx32}. OK for mainline? Uros.
diff --git a/gcc/testsuite/gcc.dg/unroll-7.c b/gcc/testsuite/gcc.dg/unroll-7.c index 70b92ba..e76d4fa 100644 --- a/gcc/testsuite/gcc.dg/unroll-7.c +++ b/gcc/testsuite/gcc.dg/unroll-7.c @@ -2,7 +2,9 @@ /* { dg-options "-O2 -fdump-rtl-loop2_unroll -funroll-loops" } */ /* { dg-require-effective-target int32plus } */ -int t(int *a) +extern int *a; + +int t(void) { int i; for (i=0;i<1000000;i++)