[llvm-dev] Comparing constant values of aggregate types for equality

Christer Swahn via llvm-dev llvm-dev at lists.llvm.org
Thu Jul 27 07:01:49 PDT 2017


Hi,

This seems to me to be a straight-forward operation and perhaps available
within LLVM's API but I've been unable to find any guidance via google /
stackoverflow.

I'm looking to do value equality comparison on aggregate types (arrays and
structs), and want to have special handling for when they are constant for
two use cases:

- Creating only a single global constant instead of several when their
values are equal and won't be modified

- Optimizing the value equality operation when both operands are constant

This is trivial with ConstantExpr::getICmp and ConstantExpr::getFCmp for
primitive types, and seems straight-forward to do recursively for structs
and arrays. So I could roll my own but I'm sure this has been done already?

However I can't find any standard implementation, can someone point me in
the right direction?

Thanks,
/Christer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170727/1d2a300a/attachment.html>


More information about the llvm-dev mailing list