Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some sources of signed integer overflow in the compiler #7231

Merged
merged 4 commits into from
Dec 13, 2022

Conversation

abadams
Copy link
Member

@abadams abadams commented Dec 12, 2022

Also, use compiler intrinsics when possible to handle overflow, as it generates faster code.

Fixes #7229

Also, use compiler intrinsics when possible to handle overflow, as it
generates faster code.
Copy link
Contributor

@steven-johnson steven-johnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I will pull this into Google for testing

src/ModulusRemainder.cpp Outdated Show resolved Hide resolved
src/Util.h Outdated Show resolved Hide resolved
@steven-johnson
Copy link
Contributor

src\CMakeFiles\Halide.dir\Util.cpp.obj /Fdsrc\CMakeFiles\Halide.dir\ /FS -c D:\build_bot\worker\halide-testbranch-main-llvm16-x86-32-windows-cmake\halide-source\src\Util.cpp
D:\build_bot\worker\halide-testbranch-main-llvm16-x86-32-windows-cmake\halide-source\src\Util.cpp(529): error C3861: '__builtin_saddll_overflow': identifier not found
D:\build_bot\worker\halide-testbranch-main-llvm16-x86-32-windows-cmake\halide-source\src\Util.cpp(557): error C3861: '__builtin_ssubll_overflow': identifier not found
D:\build_bot\worker\halide-testbranch-main-llvm16-x86-32-windows-cmake\halide-source\src\Util.cpp(597): error C3861: '__builtin_smulll_overflow': identifier not found

@abadams
Copy link
Member Author

abadams commented Dec 12, 2022

src\CMakeFiles\Halide.dir\Util.cpp.obj /Fdsrc\CMakeFiles\Halide.dir\ /FS -c D:\build_bot\worker\halide-testbranch-main-llvm16-x86-32-windows-cmake\halide-source\src\Util.cpp D:\build_bot\worker\halide-testbranch-main-llvm16-x86-32-windows-cmake\halide-source\src\Util.cpp(529): error C3861: '__builtin_saddll_overflow': identifier not found D:\build_bot\worker\halide-testbranch-main-llvm16-x86-32-windows-cmake\halide-source\src\Util.cpp(557): error C3861: '__builtin_ssubll_overflow': identifier not found D:\build_bot\worker\halide-testbranch-main-llvm16-x86-32-windows-cmake\halide-source\src\Util.cpp(597): error C3861: '__builtin_smulll_overflow': identifier not found

Oops, it's _MSC_VER, not __MSC_VER

@steven-johnson
Copy link
Contributor

Still failing ~every Windows test

@steven-johnson
Copy link
Contributor

Google integrate looks clean, just need to figure out Windows

@abadams abadams merged commit 1a4a469 into main Dec 13, 2022
ardier pushed a commit to ardier/Halide-mutation that referenced this pull request Mar 3, 2024
)

* Fix some sources of signed integer overflow in the compiler

Also, use compiler intrinsics when possible to handle overflow, as it
generates faster code.

* Fix msvc macro

* Must use result

* Actually perform the requested operation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ASAN reports signed-integer-overflow in correctness_intrinsics and correctness_code_explosion
2 participants