Page MenuHomePhabricator

Please use GitHub pull requests for new patches. Phabricator shutdown timeline

skatkov (Serguei Katkov)
User

Projects

User does not belong to any projects.

User Details

User Since
Jan 25 2017, 1:38 AM (347 w, 4 d)

Recent Activity

Mon, Aug 28

skatkov added a comment to D158503: [CGP] Remove dead PHI nodes before elimination of mostly empty blocks.

I do not see any visible regressions: https://llvm-compile-time-tracker.com/compare.php?from=692344d87357ded619d216b265a9375f4326d8fb&to=a701b7e368b70688bb4b84dafcaa43fa7c9a3649&stat=instructions:u

Mon, Aug 28, 11:00 PM · Restricted Project, Restricted Project
skatkov committed rGa701b7e368b7: [CGP] Remove dead PHI nodes before elimination of mostly empty blocks (authored by skatkov).
[CGP] Remove dead PHI nodes before elimination of mostly empty blocks
Mon, Aug 28, 9:49 PM · Restricted Project, Restricted Project
skatkov closed D158503: [CGP] Remove dead PHI nodes before elimination of mostly empty blocks.
Mon, Aug 28, 9:49 PM · Restricted Project, Restricted Project
skatkov added a reviewer for D158503: [CGP] Remove dead PHI nodes before elimination of mostly empty blocks: nikic.

Thank you, Eli.

Mon, Aug 28, 8:37 PM · Restricted Project, Restricted Project

Sun, Aug 27

skatkov updated the diff for D158503: [CGP] Remove dead PHI nodes before elimination of mostly empty blocks.

Thank you, Eli.

Sun, Aug 27, 9:53 PM · Restricted Project, Restricted Project

Aug 25 2023

skatkov added a comment to D158503: [CGP] Remove dead PHI nodes before elimination of mostly empty blocks.

Hi Eli, as no other feedbacks for a while, may I ask you to review the patch (it looks like it is a simple dead code elimination) and approve if there is no objections?

Aug 25 2023, 12:01 AM · Restricted Project, Restricted Project

Aug 22 2023

skatkov added a comment to D158503: [CGP] Remove dead PHI nodes before elimination of mostly empty blocks.

AArch64 changes look fine; it looks like atomic lowering is generating weird code that gets simplified here. (It was mostly getting simplified anyway, but after register allocation, so the register couldn't be eliminated.)

Aug 22 2023, 9:14 PM · Restricted Project, Restricted Project
skatkov requested review of D158503: [CGP] Remove dead PHI nodes before elimination of mostly empty blocks.
Aug 22 2023, 3:44 AM · Restricted Project, Restricted Project

Aug 14 2023

skatkov committed rG06dfc8400d2b: [Local] Mark Instruction argument of wouldInstructionBeTriviallyDead as const. (authored by skatkov).
[Local] Mark Instruction argument of wouldInstructionBeTriviallyDead as const.
Aug 14 2023, 1:08 AM · Restricted Project, Restricted Project
skatkov closed D157834: [Local] Mark Instruction argument of wouldInstructionBeTriviallyDead as const. NFC..
Aug 14 2023, 1:08 AM · Restricted Project, Restricted Project

Aug 13 2023

skatkov requested review of D157834: [Local] Mark Instruction argument of wouldInstructionBeTriviallyDead as const. NFC..
Aug 13 2023, 10:50 PM · Restricted Project, Restricted Project

Jul 20 2023

skatkov added a comment to D154584: Improve collectEphemeralValues and use it in CodeGenPrepare.

ping.

Jul 20 2023, 8:06 PM · Restricted Project, Restricted Project
skatkov accepted D155792: [Statepoint] Use correct RegisterClass for spilling.

Thanks.

Jul 20 2023, 2:17 AM · Restricted Project, Restricted Project

Jul 18 2023

skatkov added reviewers for D154584: Improve collectEphemeralValues and use it in CodeGenPrepare: anna, apilipenko.
Jul 18 2023, 8:01 PM · Restricted Project, Restricted Project

Jul 17 2023

skatkov added reviewers for D154584: Improve collectEphemeralValues and use it in CodeGenPrepare: hfinkel, chandlerc, spatel.

I wonder whether it will easier to review if I split this patch into three one:

  1. Use wouldInstructionBeTriviallyDead instead of checking side-effect and terminator only to extend the scope of collecting ephemeral values
  2. Use CodeMetrics utility in CodeGenPrepare
  3. Extend the algorithm for collecting ephemeral values by checking cycles (induction variable case)
Jul 17 2023, 8:04 PM · Restricted Project, Restricted Project
skatkov accepted D154954: [IRCE] Add NSW flag to main loop's indvar base.

Looks reasonable.

Jul 17 2023, 5:36 AM · Restricted Project, Restricted Project

Jul 11 2023

skatkov added a comment to D154584: Improve collectEphemeralValues and use it in CodeGenPrepare.

ping, any feedback?

Jul 11 2023, 8:10 PM · Restricted Project, Restricted Project

Jul 7 2023

skatkov accepted D154188: [IRCE] Implement runtime overflow check for computed range's end.
Jul 7 2023, 3:18 AM · Restricted Project, Restricted Project
skatkov accepted D154069: [IRCE] Parse range checks in the form of "LHS - RHS vs Limit".
Jul 7 2023, 2:38 AM · Restricted Project, Restricted Project

Jul 6 2023

skatkov added a comment to D154069: [IRCE] Parse range checks in the form of "LHS - RHS vs Limit".

One comment, other looks good...

Jul 6 2023, 11:30 PM · Restricted Project, Restricted Project
skatkov updated the diff for D154584: Improve collectEphemeralValues and use it in CodeGenPrepare.
Jul 6 2023, 9:31 PM · Restricted Project, Restricted Project
skatkov committed rG1614805eeb15: Register new assumption in a cache (authored by skatkov).
Register new assumption in a cache
Jul 6 2023, 8:53 PM · Restricted Project, Restricted Project
skatkov closed D154601: Register new assumption in a cache.
Jul 6 2023, 8:53 PM · Restricted Project, Restricted Project
skatkov added inline comments to D154584: Improve collectEphemeralValues and use it in CodeGenPrepare.
Jul 6 2023, 5:35 AM · Restricted Project, Restricted Project
skatkov requested review of D154601: Register new assumption in a cache.
Jul 6 2023, 5:34 AM · Restricted Project, Restricted Project
skatkov added a comment to D152358: [CGP] Remove operand of llvm.assume more aggressively..

We have ephemeral value trackers and other helpers, we should use those, assuming this is going forward.

Jul 6 2023, 2:16 AM · Restricted Project, Restricted Project
skatkov requested review of D154584: Improve collectEphemeralValues and use it in CodeGenPrepare.
Jul 6 2023, 2:16 AM · Restricted Project, Restricted Project

Jul 4 2023

skatkov added a comment to D152358: [CGP] Remove operand of llvm.assume more aggressively..

I've taken a look at CodeMetrics::collectEphemeralValues. It does not recognize loops with phi node as well. I can extend its detector, however it collects ephemeral values basing on conditions "I->mayHaveSideEffects() || I->isTerminator()".

Jul 4 2023, 3:07 AM · Restricted Project, Restricted Project

Jul 3 2023

skatkov added inline comments to D148244: [IRCE] Support inverted range check's predicate.
Jul 3 2023, 8:35 PM · Restricted Project, Restricted Project
skatkov accepted D148244: [IRCE] Support inverted range check's predicate.

In the commit message adds a couple of words about the reason - IRCE expects that true branch comes to loop.

Jul 3 2023, 8:33 PM · Restricted Project, Restricted Project
skatkov accepted D154391: [NFC][IRCE] Remove dead variables.
Jul 3 2023, 8:28 PM · Restricted Project, Restricted Project

Jul 2 2023

skatkov added inline comments to D154069: [IRCE] Parse range checks in the form of "LHS - RHS vs Limit".
Jul 2 2023, 10:31 PM · Restricted Project, Restricted Project
skatkov accepted D154160: [IRCE][NFC] Extract 'IV vs Limit' parsing to a separate method.
Jul 2 2023, 9:33 PM · Restricted Project, Restricted Project
skatkov accepted D154158: [IRCE][NFC] Check that Index is AddRec in the parseRangeCheckICmp.
Jul 2 2023, 9:32 PM · Restricted Project, Restricted Project
skatkov accepted D154156: [IRCE][NFC] Set Index and End together inside parseRangeCheckICmp.

LGTM with nit.

Jul 2 2023, 9:29 PM · Restricted Project, Restricted Project

Jun 30 2023

skatkov accepted D154062: [IRCE][Tests] Add tests with range checks in the form of 'iv + offset vs limit'.

You can pre-land tests without review.

Jun 30 2023, 12:23 AM · Restricted Project, Restricted Project

Jun 29 2023

skatkov added inline comments to D148244: [IRCE] Support inverted range check's predicate.
Jun 29 2023, 12:49 AM · Restricted Project, Restricted Project
skatkov added a comment to D148244: [IRCE] Support inverted range check's predicate.

Any words in git commit message?

Jun 29 2023, 12:29 AM · Restricted Project, Restricted Project
skatkov added inline comments to D148244: [IRCE] Support inverted range check's predicate.
Jun 29 2023, 12:28 AM · Restricted Project, Restricted Project

Jun 28 2023

skatkov added a comment to D152358: [CGP] Remove operand of llvm.assume more aggressively..

We have ephemeral value trackers and other helpers, we should use those, assuming this is going forward.

Jun 28 2023, 8:24 PM · Restricted Project, Restricted Project
skatkov added a comment to D152358: [CGP] Remove operand of llvm.assume more aggressively..

Our longer term plan was to stop removing assumes in CGP, so they remain available during codegen, in particular for AA purposes. Instead, we would drop assumes more aggressively earlier if they keep control flow alive.

It seems pretty likely that assumes that keep alive otherwise dead IVs are also blocking optimizations in earlier parts of the pipeline, and we would be better of dropping such assumes earlier. I'm not entirely sure what the right heuristic for that would be, but "ephemeral values of the assume include a phi node" is probably a pretty good one.

Jun 28 2023, 1:58 AM · Restricted Project, Restricted Project

Jun 27 2023

skatkov added a comment to D152358: [CGP] Remove operand of llvm.assume more aggressively..

Friendly ping...

Jun 27 2023, 8:30 PM · Restricted Project, Restricted Project

Jun 25 2023

skatkov updated the diff for D152358: [CGP] Remove operand of llvm.assume more aggressively..

Comment update.

Jun 25 2023, 9:15 PM · Restricted Project, Restricted Project
skatkov updated the diff for D152358: [CGP] Remove operand of llvm.assume more aggressively..

one more function renamed to start with lower symbol.

Jun 25 2023, 9:14 PM · Restricted Project, Restricted Project
skatkov updated the diff for D152358: [CGP] Remove operand of llvm.assume more aggressively..

please, take a look.

Jun 25 2023, 8:58 PM · Restricted Project, Restricted Project

Jun 21 2023

skatkov added a comment to D152358: [CGP] Remove operand of llvm.assume more aggressively..

Thanks a lot for review. I'll update a patch as soon as we agreed on terminology (Closure) and description of FindClosureOfWouldBeTriviallyDeadInstructions function.

Jun 21 2023, 8:05 PM · Restricted Project, Restricted Project

Jun 19 2023

skatkov added a comment to D152358: [CGP] Remove operand of llvm.assume more aggressively..

Test are updated. Code re-factored. Anything I can do to land this?

Jun 19 2023, 8:08 PM · Restricted Project, Restricted Project

Jun 16 2023

skatkov updated the diff for D152358: [CGP] Remove operand of llvm.assume more aggressively..

is it better?

Jun 16 2023, 4:04 AM · Restricted Project, Restricted Project

Jun 15 2023

skatkov committed rGd119c386cd72: [CGP] Additional tests for removing operand of assume. NFC. (authored by skatkov).
[CGP] Additional tests for removing operand of assume. NFC.
Jun 15 2023, 10:08 PM · Restricted Project, Restricted Project

Jun 14 2023

skatkov updated the diff for D152358: [CGP] Remove operand of llvm.assume more aggressively..
Jun 14 2023, 9:20 PM · Restricted Project, Restricted Project

Jun 12 2023

skatkov added a comment to D152358: [CGP] Remove operand of llvm.assume more aggressively..

ping

Jun 12 2023, 2:00 AM · Restricted Project, Restricted Project

Jun 7 2023

skatkov updated the diff for D152358: [CGP] Remove operand of llvm.assume more aggressively..

Fix comments.

Jun 7 2023, 4:18 AM · Restricted Project, Restricted Project
skatkov requested review of D152358: [CGP] Remove operand of llvm.assume more aggressively..
Jun 7 2023, 3:59 AM · Restricted Project, Restricted Project
skatkov committed rGd57ed844feb7: [CGP] Add test to show the missed case in remove llvm.assume (authored by skatkov).
[CGP] Add test to show the missed case in remove llvm.assume
Jun 7 2023, 3:21 AM · Restricted Project, Restricted Project

Jun 6 2023

skatkov added inline comments to D150862: [RISCV][CodeGenPrepare] Select the optimal base offset for GEPs with large offset.
Jun 6 2023, 7:24 PM · Restricted Project, Restricted Project

Jun 1 2023

skatkov added a comment to D151482: [LV] Add support for minimum/maximum intrinsics.

I think that adding a new reduction intrinsic sounds like a good addition. We should even have native instructions we could use for it under AArch64. For Arm we have seemed to have never added support for llvm.minimum/maximum. (There isn't a good instruction for it, and there isn't any generic expansion, but adding a new type of reduction shouldn't make that any worse).

Jun 1 2023, 7:56 PM · Restricted Project, Restricted Project

May 31 2023

skatkov added a comment to D151482: [LV] Add support for minimum/maximum intrinsics.

Looking at X86 lowering for the vector reduce intrinsics, we do not handle signed zeroes. So, we will need to introduce new intrinsics as llvm.vector.reduce.fminimum and llvm.vector.reduce.fmaximum, which is similar to existing vector reduce intrinsics but handles signed zeroes and NaN.

May 31 2023, 9:44 PM · Restricted Project, Restricted Project

May 28 2023

skatkov accepted D148001: [LICM] Reassociate & hoist sub expressions.

LGTM with comment for consideration - I do not insist.

May 28 2023, 9:19 PM · Restricted Project, Restricted Project

May 25 2023

skatkov committed rG116a31e3c399: [GuardUtils] Allow intermmediate blocks between widenable branch and deopt block (authored by skatkov).
[GuardUtils] Allow intermmediate blocks between widenable branch and deopt block
May 25 2023, 2:42 AM · Restricted Project, Restricted Project
skatkov closed D151082: [GuardUtils] Allow intermmediate blocks between widenable branch and deopt block.
May 25 2023, 2:42 AM · Restricted Project, Restricted Project

May 23 2023

skatkov added a comment to D151082: [GuardUtils] Allow intermmediate blocks between widenable branch and deopt block.

Why do we even care that an edge from a widenable condition branch terminates with a deopt? Widenable condition alone should be enough for widening.

We might want to know that a widened condition will result in a deopt for profitability purposes. We know that a deopt path is very unlikely and the runtime will be able to heal from the widening if we go that path. But we can check for these concerns separately and explicitly. We can use BFI to determine if a path is rare. We can introduce a new metadata to mark branches that can be healed after widening.

BTW, we use make implicit metadata for a similar purpose - to indicate that a branch can be "speculated" and the runtime can heal from this speculation.

May 23 2023, 9:52 PM · Restricted Project, Restricted Project
skatkov updated the diff for D151082: [GuardUtils] Allow intermmediate blocks between widenable branch and deopt block.
May 23 2023, 9:49 PM · Restricted Project, Restricted Project

May 22 2023

skatkov requested review of D151082: [GuardUtils] Allow intermmediate blocks between widenable branch and deopt block.
May 22 2023, 5:41 AM · Restricted Project, Restricted Project

May 18 2023

skatkov added a comment to D148623: [MachineCSE] Extend the scope of multi block processing..

At the moment I do not see simple way to implement https://reviews.llvm.org/D148514, so I put this on hold due to temporary busy with other stuff.

May 18 2023, 9:13 PM · Restricted Project, Restricted Project
skatkov planned changes to D148514: [BranchFolding] Remove redundant conditional branch..

At the moment, I do not see an easy way to implement this one in platform independent way. I put it on hold due to busy with other stuff.

May 18 2023, 9:12 PM · Restricted Project, Restricted Project

May 16 2023

skatkov added a comment to D149132: [LICM] Reassociate & hoist add expressions.

LGTM, @nikic, any remaining concerns?

May 16 2023, 10:20 PM · Restricted Project, Restricted Project

May 14 2023

skatkov committed rG6e19eea02bbe: [X86] Improve handling on zero constant for fminimum/fmaximum lowering (authored by skatkov).
[X86] Improve handling on zero constant for fminimum/fmaximum lowering
May 14 2023, 5:30 AM · Restricted Project, Restricted Project
skatkov closed D150249: [X86] Improve handling on zero constant for fminimum/fmaximum lowering.
May 14 2023, 5:29 AM · Restricted Project, Restricted Project

May 11 2023

skatkov updated the diff for D150249: [X86] Improve handling on zero constant for fminimum/fmaximum lowering.

PTAL

May 11 2023, 10:59 PM · Restricted Project, Restricted Project
skatkov added inline comments to D150249: [X86] Improve handling on zero constant for fminimum/fmaximum lowering.
May 11 2023, 8:11 PM · Restricted Project, Restricted Project

May 10 2023

skatkov updated the diff for D150249: [X86] Improve handling on zero constant for fminimum/fmaximum lowering.
May 10 2023, 10:37 PM · Restricted Project, Restricted Project
skatkov committed rG2713781b0cdc: [X86] Add lowering of fminimum/fmaximum for vector operands. (authored by skatkov).
[X86] Add lowering of fminimum/fmaximum for vector operands.
May 10 2023, 9:43 PM · Restricted Project, Restricted Project
skatkov closed D149844: [X86] Add lowering of fminimum/fmaximum for vector operands.
May 10 2023, 9:42 PM · Restricted Project, Restricted Project
skatkov added inline comments to D150249: [X86] Improve handling on zero constant for fminimum/fmaximum lowering.
May 10 2023, 9:05 PM · Restricted Project, Restricted Project

May 9 2023

skatkov requested review of D150249: [X86] Improve handling on zero constant for fminimum/fmaximum lowering.
May 9 2023, 11:40 PM · Restricted Project, Restricted Project
skatkov updated the diff for D149844: [X86] Add lowering of fminimum/fmaximum for vector operands.

I've pre-landed the new tests, fixed the name in the test and updated this revision.

May 9 2023, 10:55 PM · Restricted Project, Restricted Project
skatkov committed rG92663cd46412: [X86] Add test cases for fminimum/fmaximum with vector zero operands. (authored by skatkov).
[X86] Add test cases for fminimum/fmaximum with vector zero operands.
May 9 2023, 10:13 PM · Restricted Project, Restricted Project

May 5 2023

skatkov added a comment to D149844: [X86] Add lowering of fminimum/fmaximum for vector operands.

Maybe a few more vector tests? Existing tests cover the no-nans and no-signed-zeros case, they were added to avoid bloat of scalarization. E.g. a test with all checks (generic vectorized version) and two test with constant vectors to eliminate a zero check and a NaN check.

May 5 2023, 8:16 AM · Restricted Project, Restricted Project
skatkov updated the diff for D149844: [X86] Add lowering of fminimum/fmaximum for vector operands.

Handled comments.

May 5 2023, 8:15 AM · Restricted Project, Restricted Project
skatkov committed rG5b7f8d9da563: [X86] Add tests for fminimum/fmaximum for vector operands. (authored by skatkov).
[X86] Add tests for fminimum/fmaximum for vector operands.
May 5 2023, 4:57 AM · Restricted Project, Restricted Project
skatkov committed rG50cd2ff7bc5a: [X86] Avoid usage constant -1 for fminimum/fmaximum lowering (authored by skatkov).
[X86] Avoid usage constant -1 for fminimum/fmaximum lowering
May 5 2023, 2:25 AM · Restricted Project, Restricted Project
skatkov closed D149812: [X86] Avoid usage constant -1 for fminimum/fmaximum lowering.
May 5 2023, 2:24 AM · Restricted Project, Restricted Project
skatkov committed rG96e09fef3cd8: [X86] Avoid usage constant NaN for fminimum/fmaximum lowering (authored by skatkov).
[X86] Avoid usage constant NaN for fminimum/fmaximum lowering
May 5 2023, 1:43 AM · Restricted Project, Restricted Project
skatkov closed D149729: [X86] Avoid usage constant NaN for fminimum/fmaximum lowering.
May 5 2023, 1:43 AM · Restricted Project, Restricted Project

May 4 2023

skatkov requested review of D149844: [X86] Add lowering of fminimum/fmaximum for vector operands.
May 4 2023, 4:45 AM · Restricted Project, Restricted Project

May 3 2023

skatkov added a comment to D145634: [X86] Support llvm.{min,max}imum.f{16,32,64}.

I wonder whether any problems with landing this patch?

May 3 2023, 11:04 PM · Restricted Project, Restricted Project
skatkov requested review of D149812: [X86] Avoid usage constant -1 for fminimum/fmaximum lowering.
May 3 2023, 9:13 PM · Restricted Project, Restricted Project
skatkov added inline comments to D149729: [X86] Avoid usage constant NaN for fminimum/fmaximum lowering.
May 3 2023, 7:43 PM · Restricted Project, Restricted Project
skatkov updated the diff for D149729: [X86] Avoid usage constant NaN for fminimum/fmaximum lowering.
May 3 2023, 7:42 PM · Restricted Project, Restricted Project
skatkov requested review of D149729: [X86] Avoid usage constant NaN for fminimum/fmaximum lowering.
May 3 2023, 12:54 AM · Restricted Project, Restricted Project

Apr 27 2023

skatkov added inline comments to D149374: [LICM] Hoist widenable condition when it's the only non-invariant operand of its user.
Apr 27 2023, 7:25 PM · Restricted Project, Restricted Project
skatkov added a comment to D149373: [TEST][LICM] Add test cases on widenable condition hoisting opportunity.

And actually instead of NFC tag you can just say [TEST]

Apr 27 2023, 7:21 PM · Restricted Project, Restricted Project
skatkov accepted D149373: [TEST][LICM] Add test cases on widenable condition hoisting opportunity.
Apr 27 2023, 7:21 PM · Restricted Project, Restricted Project

Apr 26 2023

skatkov committed rGfaf8407aecd1: [InstSimplify] Extend handlng of fp min/max. (authored by skatkov).
[InstSimplify] Extend handlng of fp min/max.
Apr 26 2023, 8:46 PM · Restricted Project, Restricted Project
skatkov closed D147137: [InstSimplify] Extend handlng of fp min/max..
Apr 26 2023, 8:46 PM · Restricted Project, Restricted Project
skatkov added a comment to D148001: [LICM] Reassociate & hoist sub expressions.

General question: don't you want to separate sub and add handling in completely different functions.
To be honest, there will be small code duplication but in this case no need to mixup add and sub logic.
It will be easier to review and support in the future.

If duplication is a problem you can create functions for sub and add to keep first and last lines are in common.

But code for sub is exactly same as the code that handles both add and sub, with 2 lines of difference.

Apr 26 2023, 12:34 AM · Restricted Project, Restricted Project

Apr 25 2023

skatkov added inline comments to D148623: [MachineCSE] Extend the scope of multi block processing..
Apr 25 2023, 7:55 PM · Restricted Project, Restricted Project
skatkov added inline comments to D149132: [LICM] Reassociate & hoist add expressions.
Apr 25 2023, 7:33 PM · Restricted Project, Restricted Project
skatkov added a comment to D145634: [X86] Support llvm.{min,max}imum.f{16,32,64}.

I have a side question (not delaying landing this one)

It looks like this change lowers vectorized form of intrinsic in a non-optimal way.
So I wonder whether there are some plans to improve it as follow-up?

Yes, for sure. I've tried to find a way to implement vectorized version for SSE, but nothing's come to my mind. We need at least SSE2 for PCMPEQ{W,D} because all fp comparison instructions treat -0.0 and 0.0 as equal. It seems that pentium3 will suffer from not optimal fmaximum/fminimum...

Why we cannot do something like this https://godbolt.org/z/Yxfn3jTj1 ?
I mean at least for avx?

BTW. my measurements on micro benchmarking (I know micro might cause that branch predictor works good), the version https://godbolt.org/z/rEj9GPfnY is the best one for scalar but it cannot be implemented in SelectionDAG as has a CFG.

Both versions are incorrect. They don't work as expected in case of (-0.0, 0.0), (0.0, -0.0) inputs. Because comiss and max treat negative and positive zeros as equal.

Apr 25 2023, 7:34 AM · Restricted Project, Restricted Project
skatkov added a comment to D148001: [LICM] Reassociate & hoist sub expressions.

General question: don't you want to separate sub and add handling in completely different functions.
To be honest, there will be small code duplication but in this case no need to mixup add and sub logic.
It will be easier to review and support in the future.

Apr 25 2023, 3:42 AM · Restricted Project, Restricted Project