PennyLaneAI / catalyst

A JIT compiler for hybrid quantum programs in PennyLane
https://docs.pennylane.ai/projects/catalyst
Apache License 2.0
122 stars 27 forks source link

Add tbaa for Enzyme #937

Open rmoyard opened 1 month ago

rmoyard commented 1 month ago

Context:

In LLVM IR, memory does not have types, so LLVM’s own type system is not suitable for doing type based alias analysis (TBAA). Instead, metadata is added to the IR to describe a type system of a higher level language.

Enzyme uses results of TBAA to do better analysis (type and activity), some programs fail to compile because Enzyme is unable to determine type information.

Description of the Change: We create a simple TBAA that lowers the memref.load and memref.store to their llvm counter parts with a TBAA tag corresponding to the base type from MLIR. We introduce a tree class to create and hold tags.

Benefits: Enzyme benefits from it as it can do more analysis successfully.

rmoyard commented 1 month ago

[sc-48560]

rmoyard commented 1 month ago

[sc-67742]

github-actions[bot] commented 1 month ago

Hello. You may have forgotten to update the changelog! Please edit doc/changelog.md on your branch with:

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 97.89%. Comparing base (ec39190) to head (7340c24).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## fix_forloop_enzyme #937 +/- ## =================================================== Coverage 97.89% 97.89% =================================================== Files 75 75 Lines 10737 10737 Branches 1239 1239 =================================================== Hits 10511 10511 Misses 178 178 Partials 48 48 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.