llvm / circt

Circuit IR Compilers and Tools
https://circt.org
Other
1.67k stars 297 forks source link

[MooreToCore] Support pow op #7626

Open fabianschuiki opened 1 month ago

fabianschuiki commented 1 month ago

Add support for the moore.pow* ops in MooreToCore: https://chipsalliance.github.io/sv-tests-results/?v=circt_verilog+11.4.3+binary_op_pow

maerhart commented 1 month ago

We already have canonicalizers and folders that cover the simple cases here: https://github.com/llvm/circt/blob/337dad583965ea03ddcef75d9da2b5f10c23ec8d/lib/Dialect/Moore/MooreOps.cpp#L1131-L1197

The folders are automatically called during Dialect Conversion, the canonicalization aren't.

@fabianschuiki How should the a ** b case in the table be handled here? Since there's no pow op in Comb.

fabianschuiki commented 1 month ago

:+1: We could start out with a pretty dumb iterative approach? Maybe an scf.for that just goes from 0 to b and keeps multiplying a result by a? Pretty sure this almost never comes up in practice, and that would make it more of a performance issue than a correctness issue.