RESOLVED DUPLICATE of bug 272901 272902
[WASM] Avoid undefined behavior from negating INT_MIN in BBQ
https://bugs.webkit.org/show_bug.cgi?id=272902
Summary [WASM] Avoid undefined behavior from negating INT_MIN in BBQ
David Degazio
Reported 2024-04-18 09:47:07 PDT
When we're generating code for certain arithmetic instructions in BBQ, notably integer subtract, we detect if one of the operands is a constant can turn that into adding a negative. This works, but it's a bit unsavory in certain edge cases, specifically in the case where the negated constant is the negative numeric limit - this is signed overflow and undefined by the C++ standard, so we should handle it explicitly. I'm pretty sure this has no bearing on our actual runtime behavior on any platform I'm aware of though.
Attachments
Radar WebKit Bug Importer
Comment 1 2024-04-18 09:47:19 PDT
David Degazio
Comment 2 2024-04-18 10:16:58 PDT
David Degazio
Comment 3 2024-04-18 10:45:41 PDT
Actually gonna dupe this to my other bug for generally improving isel - it was pointed out that we can avoid ever doing this negation in the first place as long as we can rely on sub32/64 having good lowerings, so let's just change sub32/64 in the macro assembler. *** This bug has been marked as a duplicate of bug 272901 ***
Note You need to log in before you can comment on or make changes to this bug.