-
Notifications
You must be signed in to change notification settings - Fork 373
Open
Labels
Description
Is there a strong reason to go from PowUOp to math.ipow as opposed to lowering to a sequence of multiplications?
Is there any existing lowering from math.ipow to the core dialects?
circt/lib/Conversion/MooreToCore/MooreToCore.cpp
Lines 1379 to 1398 in 83effb2
LogicalResult | |
matchAndRewrite(PowUOp op, OpAdaptor adaptor, | |
ConversionPatternRewriter &rewriter) const override { | |
Type resultType = typeConverter->convertType(op.getResult().getType()); | |
Location loc = op->getLoc(); | |
Value zeroVal = hw::ConstantOp::create(rewriter, loc, APInt(1, 0)); | |
// zero extend both LHS & RHS to ensure the unsigned integers are | |
// interpreted correctly when calculating power | |
auto lhs = comb::ConcatOp::create(rewriter, loc, zeroVal, adaptor.getLhs()); | |
auto rhs = comb::ConcatOp::create(rewriter, loc, zeroVal, adaptor.getRhs()); | |
// lower the exponentiation via MLIR's math dialect | |
auto pow = mlir::math::IPowIOp::create(rewriter, loc, lhs, rhs); | |
rewriter.replaceOpWithNewOp<comb::ExtractOp>(op, resultType, pow, 0); | |
return success(); | |
} | |
}; |