On Wed, Jun 19, 2013 at 12:35 PM, Bin.Cheng <amker.ch...@gmail.com> wrote: > On Wed, Jun 19, 2013 at 4:43 PM, Richard Biener > <richard.guent...@gmail.com> wrote: >> On Wed, Jun 19, 2013 at 10:04 AM, Bin.Cheng <amker.ch...@gmail.com> wrote: >>> Hi, >>> For test case gcc.dg/tree-ssa/ivopt_inter_2.c >>> >>> #ifndef TYPE >>> #define TYPE char* >>> #endif >>> >>> extern char a[]; >>> >>> /* Can not infer loop iteration from array -- exit test can not be >>> replaced. */ >>> void foo (unsigned int i_width, TYPE dst) >>> { >>> unsigned long long i = 0; >>> unsigned long long j = 0; >>> for ( ; j < i_width; ) >>> { >>> *dst = a[i]; >>> dst++; >>> i += 2; >>> j += 1; >>> } >>> } >>> >>> /* { dg-final { scan-tree-dump-times "Replacing" 0 "ivopts"} } */ >>> /* { dg-final { cleanup-tree-dump "ivopts" } } */ >>> >>> It checks whether the test is eliminated by address iv candidate, >>> which is fragile. >>> Giving the ivopt dump file : >>> >>> foo (unsigned int i_width, char * dst) >>> { >>> long long unsigned int j; >>> long long unsigned int i; >>> long long unsigned int _4; >>> char _9; >>> long long unsigned int _18; >>> >>> <bb 2>: >>> _18 = (long long unsigned int) i_width_7(D); >>> if (_18 != 0) >>> goto <bb 3>; >>> else >>> goto <bb 7>; >>> >>> <bb 3>: >>> >>> <bb 4>: >>> # j_21 = PHI <j_13(5), 0(3)> >>> _9 = MEM[symbol: a, index: j_21, step: 2, offset: 0B]; >>> MEM[base: dst_5(D), index: j_21, offset: 0B] = _9; >>> j_13 = j_21 + 1; >>> if (j_13 < _18) >>> goto <bb 5>; >>> else >>> goto <bb 6>; >>> >>> <bb 5>: >>> goto <bb 4>; >>> >>> <bb 6>: >>> >>> <bb 7>: >>> return; >>> } >>> >>> It's possible to have "if (j_13 < _18)" eliminated into "if (j_13 != >>> _18)", and the case would fail because of dump message "Replacing exit >>> test: if (j_13 < _18)" >>> >>> Same story for ivopt_mult_3.c >>> >>> Any idea how it should be handled? >> >> Probably by checking for the real issue - I suppose at some point >> the number of iterations was infered to be zero or one. >> > But the analyze result of loop is: > > > Analyzing # of iterations of loop 1 > exit condition [1, + , 1] < (long long unsigned int) i_width_7(D) > bounds on difference of bases: 0 ... 18446744073709551614 > result: > # of iterations (long long unsigned int) i_width_7(D) + > 18446744073709551615, bounded by 18446744073709551614 > number of iterations (long long unsigned int) i_width_7(D) + > 18446744073709551615
Which looks correct. Richard. > > -- > Best Regards.