Hi, I have the following code as an example: int j=-1; for (int i = 0; i < 100; ++i) { if (c[i] > 0.) { j++; e[j] = d[i]; } } How can I use LLVM's existing SCEV module to infer that e[j] could be consecutive if consecutive iterations' conditions are true? Bests, Bangtian -- *Bangtian Liu 刘 邦天 * *CS PhD Candidate* *Department of Computer Science University of TorontoPratt 265C, 6 King's College Road, Toronto, ON M5S 3G4, Canada* -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20211106/24ab4a4c/attachment.html>
Maybe llvm::PredicatedScalarEvolution is the one you’re looking for. IIRC, it was created for loop versioning, so it might insert some runtime checks. -Min> On Nov 6, 2021, at 12:44 AM, Bangtian Liu via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > Hi, > > I have the following code as an example: > int j=-1; > for (int i = 0; i < 100; ++i) > { > if (c[i] > 0.) { > j++; > e[j] = d[i]; > } } > > How can I use LLVM's existing SCEV module to infer that e[j] could be consecutive if consecutive iterations' conditions are true? > > Bests, > > Bangtian > > > > -- > Bangtian Liu 刘 邦天 > CS PhD Candidate > > Department of Computer Science > University of Toronto > Pratt 265C, 6 King's College Road, Toronto, ON M5S 3G4, Canada > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://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/20211106/ed00d0fc/attachment.html>
I don't believe we have any good way to model a conditionally incremented induction variable when the condition is loop varying and data dependent. This is not exactly a common or interesting case. Just out of curiosity, what do you expect to be able to do with this loop optimization wise? We could maybe vectorize if we had bounds information on 'c', but that's about all I see here. Philip On 11/6/21 12:44 AM, Bangtian Liu via llvm-dev wrote:> > Hi, > > I have the following code as an example: > int j=-1; > for (int i = 0; i < 100; ++i) > { > if (c[i] > 0.) { > j++; > e[j] = d[i]; > } } > > How can I use LLVM's existing SCEV module to infer that e[j] could be > consecutive if consecutive iterations' conditions are true? > > Bests, > > Bangtian > > > > -- > /*Bangtian Liu 刘 邦天 */ > /*CS PhD Candidate > */ > > /*Department of Computer Science > **University of Toronto > Pratt 265C, 6 King's College Road, Toronto, ON M5S 3G4, Canada*/ > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://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/20211112/5777d4bf/attachment.html>