[LLVMdev] getIntrinsicID() optimization, mark 2

Jeffrey Yasskin jyasskin at google.com
Sat Oct 17 10:03:15 PDT 2009


It is possible to change the name of a Function with Value::setName,
so this patch _could_ cause incorrect answers. You should add a test
that calls setName("intrinsic.name") to make sure this keeps working,
regardless of where this patch goes.  You might be able to catch such
events in the ValueSymbolTable and update the intrinsic ID, but I
can't find an obvious place to put that code.

I also noticed that getIntrinsicID (implemented in Intrinsics.gen) is
a switch statement on the first letter of the intrinsic name plus a
long series of
    if (Len == 16 && !memcmp(Name, "llvm.alpha.umulh", 16)) return
Intrinsic::alpha_umulh;
    if (Len > 15 && !memcmp(Name, "llvm.annotation.", 16)) return
Intrinsic::annotation;
    if (Len > 20 && !memcmp(Name, "llvm.arm.neon.vabals.", 21)) return
Intrinsic::arm_neon_vabals;
...

There has to be a more efficient way to do this. If nothing else, the
first 6 characters of that memcmp are always equal, and for groups of
intrinsics like llvm.arm.neon.v*, a trie-like search would be better.
llvm/ADT/Trie.h doesn't quite do what this needs (no prefix
searching), and it looks like it should be changed to use StringRefs
instead of std::strings during the search, but fixing and using it
here might be the right thing to do.

On Sat, Oct 17, 2009 at 3:48 AM, Nicolas Capens <nicolas at capens.net> wrote:
> Any takers? This patch improves on the previous one by making
> getIntrinsicID() inline.
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>




More information about the llvm-dev mailing list