https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88109
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Kyrylo Tkachov <[email protected]>: https://gcc.gnu.org/g:00a0e7d2375850a0256c392005e10c7d28aeac97 commit r17-3504-g00a0e7d2375850a0256c392005e10c7d28aeac97 Author: Kyrylo Tkachov <[email protected]> Date: Thu Aug 20 08:47:01 2026 +0200 tree: make TYPE_OVERFLOW_SANITIZED accept vector types UBSan instruments signed integral vector arithmetic. However, TYPE_OVERFLOW_SANITIZED only accepts scalar integral types. Folding can use the false result to remove a vector operation before UBSan instruments it. For example: typedef int v4si __attribute__ ((vector_size (16))); v4si f (v4si x) { return -(-x); } Both negations can overflow. The scalar-only predicate lets fold-const reduce the function to x and remove both diagnostics. aarch64 -O2 -fsanitize=signed-integer-overflow -fsanitize-trap=signed-integer-overflow before: f: ret After: f: fmov w0, s0 negs w0, w0 bvs .L27 ... neg v31.4s, v0.4s fmov w0, s31 negs w0, w0 bvs .L27 ... ret .L27: brk #1000 Use ANY_INTEGRAL_TYPE_P so the predicate also accepts integral vector types. The test checks that both vector negations remain for UBSan instrumentation. Bootstrapped and tested on aarch64-none-linux-gnu. Tested on x86_64-pc-linux-gnu. gcc/ChangeLog: PR sanitizer/88109 * tree.h (TYPE_OVERFLOW_SANITIZED): Use ANY_INTEGRAL_TYPE_P. gcc/testsuite/ChangeLog: PR sanitizer/88109 * c-c++-common/ubsan/overflow-vec-3.c: New test. Signed-off-by: Kyrylo Tkachov <[email protected]>
