> -----Original Message-----
> From: Richard Biener [mailto:[email protected]]
> Sent: 08 January 2014 14:42
> To: Paulo Matos
> Cc: Andrew Haley; [email protected]; Jan Hubicka
> Subject: Re: Infinite number of iterations in loop [v850, mep]
>
> Well. We have
>
> Loop 2 is simple:
> simple exit 5 -> 7
> infinite if: (expr_list:REG_DEP_TRUE (and:SI (reg:SI 76)
> (const_int 1 [0x1]))
> (nil))
> number of iterations: (lshiftrt:SI (plus:SI (minus:SI (reg:SI 68 [ D.1398 ])
> (reg:SI 64 [ ivtmp___6 ]))
> (const_int -2 [0xfffffffffffffffe]))
> (const_int 1 [0x1]))
> upper bound: 2147483646
> realistic bound: -1
> Doloop: Possible infinite iteration case.
> Doloop: The loop is not suitable.
>
> as we replaced the induction variable by a pointer induction with
> step 2. So this might be a very common issue for RTL loop opts,
> the upper bound of the IV is 2 * N in this case, so 2 * N & 1
> should be always false and thus "infinite" be optimized.
>
> (insn 34 33 36 3 (parallel [
> (set (reg:SI 76)
> (plus:SI (reg/v:SI 71 [ N ])
> (reg/v:SI 71 [ N ])))
> (clobber (reg:CC 32 psw))
> ]) 21 {addsi3}
> (expr_list:REG_UNUSED (reg:CC 32 psw)
> (nil)))
>
> that doesn't look too difficult to do with the above definition.
> nonzero_bits might be of use here, not sure (not my area of
> expertise).
>
I am trying to do something that shouldn't be too hard with the current df
infrastructure but I don't think I am doing it the right way.
Once I have the assumption (and:SI (reg:SI 76) (const_int 1 [0x1]))
I need to reach the definition of reg 76 which is insn 34. Generally we can
only do this if there if no other definition of reg 76 except one in a
dominator basic block.
The CFG looks like:
BB2
/ \
BB3 BB7
| \
BB6 exit
\
BB4 ---------
/ \
BB5 BB9
| \ |
BB8 BB7 (exit) BB4 (loop)
|
BB6 (loop)
BB3 contains insn 34 and there's no other definition of reg 76 in loop
BB6->BB4->BB5->BB8 or the inner BB4->BB9.
Is there a way to do this search for definition of reg 76 automatically? I can
see a df_find_def, however this requires me to have insn 34 already. I need to
search for it. Is there anything in GCC to do this already?
I am sure GCC must be doing this already somewhere.
Cheers,
Paulo Matos
> Richard.
>