[llvm-dev] Loop identification
Krzysztof Parzyszek via llvm-dev
llvm-dev at lists.llvm.org
Fri Jan 13 08:19:37 PST 2017
Hi Catello,
LLVM does have a "loop idiom recognition" pass which, in principle, does
exactly that kind of a thing: it recognizes loops that perform
memcpy/memset operations. It does not recognize any target-specific
idioms though and there isn't really much in it that would make such
recognition easier. We have some cases like yours on Hexagon, where we
want to replace certain loops with Hexagon-specific intrinsics, and the
way we do it is that we have (in our own compiler) a separate pass that
runs at around the same time, but which does "Hexagon-specific loop
idiom recognition". That pass is not present in llvm.org, mostly because
it hooks up a target specific pass in a way that is not "officially
supported".
If LLVM supported adding such target-specific passes at that point in
the optimization pipeline, you could just write your own pass and plug
it in there.
-Krzysztof
On 1/13/2017 9:45 AM, Catello Cioffi via llvm-dev wrote:
> Good afternoon,
>
> I'm working on modifying the Mips backend in order to add new
> functionalities. I've successfully implemented the intrinsics, but I
> want to recognize a pattern like this:
>
> int seq[max];
> int cnt = 0;
>
> for (int i = 0; i < max; i++)
> {
> for (int j = 0; i < 16; i++)
> {
> char hn = (seq[i] & (3<<(j*2)) >> (j*2);
> if (hn == 2)
> {
> cnt++;
> }
> }
> }
>
>
> and transform it into something like:
>
> int seq[max];
> int cnt = 0;
>
> for (int i = 0; i < max; i++)
> {
> cnt += intrinsic(seq[i], 2);
> }
>
> Do you know what I can use to transform the loop? Or if exists something
> similar in LLVM?
>
> Thanks,
>
> Catello
>
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
More information about the llvm-dev
mailing list