On 20-Mar-09, at 5:32 PM, Anthony Danalis wrote:> I'm having some trouble with getTripCount() ... again. In particular
> it fails in the first of the following two examples, although it works
> for the second. By fails, I mean it returns NULL.
The main difference between the two cases below is that in case 1,
LLVM can't prove that "a" and "ip" don't alias (the
fact that ip is a
"const int*" doesn't help, since that only tells the compiler to
not
allow writing to ip's contents directly, not that the contents of ip
remain constant). In case 2, ip points to the local stack, and
therefore "a" can't possibly alias it.
So, in case 1, the write to a[k] inside the loop might actually modify
ip[2], and thus the loop bound is not loop-invariant.
Stefanus
> ---------- example 1 ----------
> test1(int *a, const int *ip) {
> int k;
>
> for (k = 0; k < ip[2]; ++k) {
> a[k] = (k+11)/(k+2);
> }
> }
>
> ---------- example 2 ----------
> test2(int *a) {
> int k, ip[4];
>
> vbar(ip, 4, 7);
>
> for (k = 0; k < ip[2]; ++k) {
> a[k] = (k+11)/(k+2);
> }
> }
>
>
> However, in both cases the trip count is the same and equally
> undecidable, since "vbar()" is an external function.
>
> Note that in each example that is the only code in the file and I am
> running my pass as:
> opt -O1 -licm -load ... -mypass < test.bc > /dev/null
>
> Any suggestions?
>
> thanks,
> Anthony
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
--
Stefanus Du Toit <stefanus.dutoit at rapidmind.com>
RapidMind Inc.
phone: +1 519 885 5455 x116 -- fax: +1 519 885 1463