This support was removed years ago from indvars. We don't need canonical induction variables any more as all analysis are done on SCEVs. The SCEV generator can transform them even without the need for explicit canonical induction variables. Best, Tobias On Wed, Aug 9, 2017, at 14:23, Anastasiya Ruzhanskaya via llvm-dev wrote:> The files of this strange pass are described here > http://reviews.legup.org/rLEGUP54ca7c2bb15d84116baf47bce67256d3803720d9 > . > I wonderwhy the most uptodate -indvars pass can't do the same. > > 2017-08-09 14:18 GMT+02:00 Anastasiya Ruzhanskaya < > anastasiya.ruzhanskaya at frtk.ru>: > > > Hello, > > I have this piece of code: > > int main() { > > int m = 0; > > // int i, j, k; > > // int N = f()%10; > > for (int l = 0; l < 1000; l+=4) > > printf("%d", l); > > > > I am sure, that llvm is capable to convert this into canonical induction > > variable, but even with O3 > > define i32 @main() #0 { > > br label %2 > > > > ; <label>:1 ; preds = %2 > > ret i32 0 > > > > ; <label>:2 ; preds = %0, %2 > > %l.01 = phi i32 [ 0, %0 ], [ %4, %2 ] > > %3 = tail call i32 (i8*, ...) @printf(i8* nonnull getelementptr inbounds > > ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %l.01) > > %4 = add nuw nsw i32 %l.01, 4 > > %5 = icmp slt i32 %4, 1000 > > br i1 %5, label %2, label %1 > > } > > > > I have this assembler. > > I know there is indvars2 pass ( it is under llvm license but used only in > > LegUp project - as I understood, surfing the Internet), which is good in > > changing induction variables. > > > > How can I achieve that this cycle will have a canonical indvar? > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
SCEV , seems to me that this is a little disadvantage ( I am not an expert by now in llvm, but think so), does not keep a cmp instruction, where someone can find a value , with which an induction variable is compared. When it is impossible to determine a trip count, that information can be useful ( hope not only for me). Still after receiving a block where this instruction is, it is not really hard to find the ICmp, but still... 2017-08-09 14:28 GMT+02:00 Tobias Grosser <tobias.grosser at inf.ethz.ch>:> This support was removed years ago from indvars. We don't need canonical > induction variables any more as all analysis are done on SCEVs. The SCEV > generator can transform them even without the need for explicit > canonical induction variables. > > Best, > Tobias > > On Wed, Aug 9, 2017, at 14:23, Anastasiya Ruzhanskaya via llvm-dev > wrote: > > The files of this strange pass are described here > > http://reviews.legup.org/rLEGUP54ca7c2bb15d84116baf47bce67256d3803720d9 > > . > > I wonderwhy the most uptodate -indvars pass can't do the same. > > > > 2017-08-09 14:18 GMT+02:00 Anastasiya Ruzhanskaya < > > anastasiya.ruzhanskaya at frtk.ru>: > > > > > Hello, > > > I have this piece of code: > > > int main() { > > > int m = 0; > > > // int i, j, k; > > > // int N = f()%10; > > > for (int l = 0; l < 1000; l+=4) > > > printf("%d", l); > > > > > > I am sure, that llvm is capable to convert this into canonical > induction > > > variable, but even with O3 > > > define i32 @main() #0 { > > > br label %2 > > > > > > ; <label>:1 ; preds = %2 > > > ret i32 0 > > > > > > ; <label>:2 ; preds = %0, %2 > > > %l.01 = phi i32 [ 0, %0 ], [ %4, %2 ] > > > %3 = tail call i32 (i8*, ...) @printf(i8* nonnull getelementptr > inbounds > > > ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %l.01) > > > %4 = add nuw nsw i32 %l.01, 4 > > > %5 = icmp slt i32 %4, 1000 > > > br i1 %5, label %2, label %1 > > > } > > > > > > I have this assembler. > > > I know there is indvars2 pass ( it is under llvm license but used only > in > > > LegUp project - as I understood, surfing the Internet), which is good > in > > > changing induction variables. > > > > > > How can I achieve that this cycle will have a canonical indvar? > > > > > _______________________________________________ > > 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/20170809/fc01b197/attachment-0001.html>
...or maybe the second operand of ICmp 2017-08-09 14:51 GMT+02:00 Anastasiya Ruzhanskaya < anastasiya.ruzhanskaya at frtk.ru>:> SCEV , seems to me that this is a little disadvantage ( I am not an expert > by now in llvm, but think so), does not keep a cmp instruction, where > someone can find a value , with which an induction variable is compared. > When it is impossible to determine a trip count, that information can be > useful ( hope not only for me). Still after receiving a block where this > instruction is, it is not really hard to find the ICmp, but still... > > 2017-08-09 14:28 GMT+02:00 Tobias Grosser <tobias.grosser at inf.ethz.ch>: > >> This support was removed years ago from indvars. We don't need canonical >> induction variables any more as all analysis are done on SCEVs. The SCEV >> generator can transform them even without the need for explicit >> canonical induction variables. >> >> Best, >> Tobias >> >> On Wed, Aug 9, 2017, at 14:23, Anastasiya Ruzhanskaya via llvm-dev >> wrote: >> > The files of this strange pass are described here >> > http://reviews.legup.org/rLEGUP54ca7c2bb15d84116baf47bce67256d3803720d9 >> > . >> > I wonderwhy the most uptodate -indvars pass can't do the same. >> > >> > 2017-08-09 14:18 GMT+02:00 Anastasiya Ruzhanskaya < >> > anastasiya.ruzhanskaya at frtk.ru>: >> > >> > > Hello, >> > > I have this piece of code: >> > > int main() { >> > > int m = 0; >> > > // int i, j, k; >> > > // int N = f()%10; >> > > for (int l = 0; l < 1000; l+=4) >> > > printf("%d", l); >> > > >> > > I am sure, that llvm is capable to convert this into canonical >> induction >> > > variable, but even with O3 >> > > define i32 @main() #0 { >> > > br label %2 >> > > >> > > ; <label>:1 ; preds = %2 >> > > ret i32 0 >> > > >> > > ; <label>:2 ; preds = %0, %2 >> > > %l.01 = phi i32 [ 0, %0 ], [ %4, %2 ] >> > > %3 = tail call i32 (i8*, ...) @printf(i8* nonnull getelementptr >> inbounds >> > > ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %l.01) >> > > %4 = add nuw nsw i32 %l.01, 4 >> > > %5 = icmp slt i32 %4, 1000 >> > > br i1 %5, label %2, label %1 >> > > } >> > > >> > > I have this assembler. >> > > I know there is indvars2 pass ( it is under llvm license but used >> only in >> > > LegUp project - as I understood, surfing the Internet), which is good >> in >> > > changing induction variables. >> > > >> > > How can I achieve that this cycle will have a canonical indvar? >> > > >> > _______________________________________________ >> > 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/20170809/b720d34c/attachment.html>
Could you please clarify for me: was the elimination of this pass also due to some performance issues? So, if I will insert this pass now and perform modification of the graph, will be there any performance impact? 2017-08-09 14:28 GMT+02:00 Tobias Grosser <tobias.grosser at inf.ethz.ch>:> This support was removed years ago from indvars. We don't need canonical > induction variables any more as all analysis are done on SCEVs. The SCEV > generator can transform them even without the need for explicit > canonical induction variables. > > Best, > Tobias > > On Wed, Aug 9, 2017, at 14:23, Anastasiya Ruzhanskaya via llvm-dev > wrote: > > The files of this strange pass are described here > > http://reviews.legup.org/rLEGUP54ca7c2bb15d84116baf47bce67256d3803720d9 > > . > > I wonderwhy the most uptodate -indvars pass can't do the same. > > > > 2017-08-09 14:18 GMT+02:00 Anastasiya Ruzhanskaya < > > anastasiya.ruzhanskaya at frtk.ru>: > > > > > Hello, > > > I have this piece of code: > > > int main() { > > > int m = 0; > > > // int i, j, k; > > > // int N = f()%10; > > > for (int l = 0; l < 1000; l+=4) > > > printf("%d", l); > > > > > > I am sure, that llvm is capable to convert this into canonical > induction > > > variable, but even with O3 > > > define i32 @main() #0 { > > > br label %2 > > > > > > ; <label>:1 ; preds = %2 > > > ret i32 0 > > > > > > ; <label>:2 ; preds = %0, %2 > > > %l.01 = phi i32 [ 0, %0 ], [ %4, %2 ] > > > %3 = tail call i32 (i8*, ...) @printf(i8* nonnull getelementptr > inbounds > > > ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %l.01) > > > %4 = add nuw nsw i32 %l.01, 4 > > > %5 = icmp slt i32 %4, 1000 > > > br i1 %5, label %2, label %1 > > > } > > > > > > I have this assembler. > > > I know there is indvars2 pass ( it is under llvm license but used only > in > > > LegUp project - as I understood, surfing the Internet), which is good > in > > > changing induction variables. > > > > > > How can I achieve that this cycle will have a canonical indvar? > > > > > _______________________________________________ > > 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/20170813/5b2a2c04/attachment.html>
In certain rare (but AFAIR important) cases the indvar canonicalization reduced performance and LLVM was not successful in recovering the optimal IR during later strength reduciton passes. Best, Tobias On Sun, Aug 13, 2017, at 18:46, Anastasiya Ruzhanskaya via llvm-dev wrote:> Could you please clarify for me: was the elimination of this pass also > due > to some performance issues? So, if I will insert this pass now and > perform > modification of the graph, will be there any performance impact? > > 2017-08-09 14:28 GMT+02:00 Tobias Grosser <tobias.grosser at inf.ethz.ch>: > > > This support was removed years ago from indvars. We don't need canonical > > induction variables any more as all analysis are done on SCEVs. The SCEV > > generator can transform them even without the need for explicit > > canonical induction variables. > > > > Best, > > Tobias > > > > On Wed, Aug 9, 2017, at 14:23, Anastasiya Ruzhanskaya via llvm-dev > > wrote: > > > The files of this strange pass are described here > > > http://reviews.legup.org/rLEGUP54ca7c2bb15d84116baf47bce67256d3803720d9 > > > . > > > I wonderwhy the most uptodate -indvars pass can't do the same. > > > > > > 2017-08-09 14:18 GMT+02:00 Anastasiya Ruzhanskaya < > > > anastasiya.ruzhanskaya at frtk.ru>: > > > > > > > Hello, > > > > I have this piece of code: > > > > int main() { > > > > int m = 0; > > > > // int i, j, k; > > > > // int N = f()%10; > > > > for (int l = 0; l < 1000; l+=4) > > > > printf("%d", l); > > > > > > > > I am sure, that llvm is capable to convert this into canonical > > induction > > > > variable, but even with O3 > > > > define i32 @main() #0 { > > > > br label %2 > > > > > > > > ; <label>:1 ; preds = %2 > > > > ret i32 0 > > > > > > > > ; <label>:2 ; preds = %0, %2 > > > > %l.01 = phi i32 [ 0, %0 ], [ %4, %2 ] > > > > %3 = tail call i32 (i8*, ...) @printf(i8* nonnull getelementptr > > inbounds > > > > ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %l.01) > > > > %4 = add nuw nsw i32 %l.01, 4 > > > > %5 = icmp slt i32 %4, 1000 > > > > br i1 %5, label %2, label %1 > > > > } > > > > > > > > I have this assembler. > > > > I know there is indvars2 pass ( it is under llvm license but used only > > in > > > > LegUp project - as I understood, surfing the Internet), which is good > > in > > > > changing induction variables. > > > > > > > > How can I achieve that this cycle will have a canonical indvar? > > > > > > > _______________________________________________ > > > LLVM Developers mailing list > > > llvm-dev at lists.llvm.org > > > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev