Anastasiya Ruzhanskaya via llvm-dev
2017-Jul-25 16:12 UTC
[llvm-dev] loop canonical variables
Hello, I need to perform the analysis of loop induction variables. However, as I understood, directly it is possible to extract only a canonical induction variable which is only one. If I have multiple induction variables with the step not one, are there any methods to extract their phi node? int a[10]; int b[10]; for (int i = 0, j = 1; i < 10, j < 10; i++, j+=2) { a[i] = i+1; b[j] = j+1; } printf("%d",(b[1] + a[1])); return (b[1] + a[1]); this is a brief example, I want to track i and j (smth is not initialized in this code, but it doesn't matter) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170725/5f3b4ab0/attachment.html>
There is Loop::getCanonicalInductionVariable() You may need to run the "-indvars" (IndVarSimplify) pass before it returns a value. I am not sure it normalizes the step size to 1 in all cases. Michael 2017-07-25 18:12 GMT+02:00 Anastasiya Ruzhanskaya via llvm-dev <llvm-dev at lists.llvm.org>:> Hello, > I need to perform the analysis of loop induction variables. However, as I > understood, directly it is possible to extract only a canonical induction > variable which is only one. If I have multiple induction variables with the > step not one, are there any methods to extract their phi node? > > int a[10]; > int b[10]; > for (int i = 0, j = 1; i < 10, j < 10; i++, j+=2) { > a[i] = i+1; > b[j] = j+1; > } > printf("%d",(b[1] + a[1])); > return (b[1] + a[1]); > > this is a brief example, I want to track i and j (smth is not initialized in > this code, but it doesn't matter) > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >
Anastasiya Ruzhanskaya via llvm-dev
2017-Jul-25 17:32 UTC
[llvm-dev] loop canonical variables
I call this function and it returns only "i" in my example. Are there any ways to return "j" also? 2017-07-25 19:11 GMT+02:00 Michael Kruse <llvmdev at meinersbur.de>:> There is Loop::getCanonicalInductionVariable() > > You may need to run the "-indvars" (IndVarSimplify) pass before it > returns a value. I am not sure it normalizes the step size to 1 in all > cases. > > Michael > > 2017-07-25 18:12 GMT+02:00 Anastasiya Ruzhanskaya via llvm-dev > <llvm-dev at lists.llvm.org>: > > Hello, > > I need to perform the analysis of loop induction variables. However, as I > > understood, directly it is possible to extract only a canonical induction > > variable which is only one. If I have multiple induction variables with > the > > step not one, are there any methods to extract their phi node? > > > > int a[10]; > > int b[10]; > > for (int i = 0, j = 1; i < 10, j < 10; i++, j+=2) { > > a[i] = i+1; > > b[j] = j+1; > > } > > printf("%d",(b[1] + a[1])); > > return (b[1] + a[1]); > > > > this is a brief example, I want to track i and j (smth is not > initialized in > > this code, but it doesn't matter) > > > > _______________________________________________ > > LLVM Developers mailing list > > llvm-dev at lists.llvm.org > > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170725/bc99ef42/attachment.html>