[PATCH] D134744: [clang][Interp] Implement rem opcode
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 30 05:52:21 PDT 2022
aaron.ballman added inline comments.
================
Comment at: clang/lib/AST/Interp/Interp.h:170
+
+ if (LHS.isSigned() && LHS.isMin() && RHS.isNegative() && RHS.isMinusOne()) {
+ APSInt LHSInt = LHS.toAPSInt();
----------------
I really like how clear and generalized this predicate is!
================
Comment at: clang/lib/AST/Interp/Interp.h:164
+
+ if (RHS.isZero()) {
+ const SourceInfo &Loc = S.Current->getSource(OpPC);
----------------
tbaeder wrote:
> shafik wrote:
> > You also need to catch when the result is not representable e.g `INT_MIN % -1`
> >
> > see `CheckICE(...)`
> I added the check here some lines below; Is that alright? If so I'd add the same code to the `div()` implementation.
Looks correct to me.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D134744/new/
https://reviews.llvm.org/D134744
More information about the cfe-commits
mailing list