Add ModArithType folding hooks#3067
Conversation
|
Note this is rebased over #3065 but the commits get squashed by copybara. |
9382181 to
f9dec32
Compare
f9dec32 to
07b95f3
Compare
| res = lw + rw; | ||
| break; | ||
| case ModOp::Sub: | ||
| res = lw + mw - rw.urem(mw); |
There was a problem hiding this comment.
Why add the modulus here? Is there an assumption somewhere that values should not be negative? c.f. my confusion here
There was a problem hiding this comment.
I see the urem below... any other reason?
There was a problem hiding this comment.
Ignoring the urem at the end, I think until ModArithToArith is updated to support anything except standard representatives in [0, q), we will have to maintain that invariant in the folders or else the lowerings may break.
| auto rnsType = dyn_cast_if_present<RNSType>(type); | ||
| if (!rnsType) return nullptr; | ||
| auto op = rns::ConstantOp::create(builder, loc, rnsType, *this); | ||
| return op.getOperation(); |
There was a problem hiding this comment.
How is that different than return op?
There was a problem hiding this comment.
What you wrote indeed compiles, but that's because, technically speaking, the tablegen-generated classes like ConstantOp inherit from ::mlir::Op (cf here) which wrap an Operation *, and these classes have an implicit typecaster from ::mlir::Op to Operation *. Usually when I explicitly want an Operation *, however, I'll try to make it more explicit and ask for the Operation * explicitly.
|
Mostly questions for my own understanding. Love where this is headed! |
b95aa11 to
b88f293
Compare
This change extends mod_arith folders to support RNS using the new Limbwise- attribute and op interfaces Part of #97 PiperOrigin-RevId: 933486917
b88f293 to
1119f1f
Compare
Add ModArithType folding hooks
This change extends mod_arith folders to support RNS using the new Limbwise- attribute and op interfaces
Part of #97