Hi All, Skim through Hexagon backend, I notice there is HexagonCommonGEP.cpp which seems try to do something on `getelementptr` LLVM instruction. But what exactly it want to do? Anyone knows? Thanks. Regards, chenwj -- Wei-Ren Chen (陳韋任) Homepage: https://people.cs.nctu.edu.tw/~chenwj -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170614/454959ce/attachment.html>
Krzysztof Parzyszek via llvm-dev
2017-Jun-14 13:11 UTC
[llvm-dev] What is HexagonCommonGEP.cpp for?
On 6/14/2017 7:44 AM, 陳韋任 via llvm-dev wrote:> > Skim through Hexagon backend, I notice there is HexagonCommonGEP.cpp > which seems > try to do something on `getelementptr` LLVM instruction. But what > exactly it want to do? > Anyone knows?Each getelementptr is a chain that starts with a pointer, followed by an index, which together produce a new pointer. That new pointer coupled with the next index on the operand list produced yet another pointer, and so on. Each GEP can actually be broken up into shorter GEPs, where the next one starts at the address generated by the previous one. It is fairly common to have GEP instructions that in their entirety generate different pointers, but where the initial few pointers are identical. The core task of HexagonCommonGEP is to isolate the initial identical addresses into their own GEP instructions. It then does several other things, like finding the best placement of the commoned GEPs (with respect to loop invariance), etc. -Krzysztof -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Sounds like you break a single getelementptr into a few smaller ones, then do CSE-like optimization? 2017-06-14 21:11 GMT+08:00 Krzysztof Parzyszek via llvm-dev < llvm-dev at lists.llvm.org>:> On 6/14/2017 7:44 AM, 陳韋任 via llvm-dev wrote: > >> >> Skim through Hexagon backend, I notice there is HexagonCommonGEP.cpp >> which seems >> try to do something on `getelementptr` LLVM instruction. But what exactly >> it want to do? >> Anyone knows? >> > > Each getelementptr is a chain that starts with a pointer, followed by an > index, which together produce a new pointer. That new pointer coupled with > the next index on the operand list produced yet another pointer, and so on. > Each GEP can actually be broken up into shorter GEPs, where the next one > starts at the address generated by the previous one. It is fairly common to > have GEP instructions that in their entirety generate different pointers, > but where the initial few pointers are identical. The core task of > HexagonCommonGEP is to isolate the initial identical addresses into their > own GEP instructions. It then does several other things, like finding the > best placement of the commoned GEPs (with respect to loop invariance), etc. > > -Krzysztof > > -- > Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted > by The Linux Foundation > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-- Wei-Ren Chen (陳韋任) Homepage: https://people.cs.nctu.edu.tw/~chenwj -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170614/b567994c/attachment.html>