]> git.ipfire.org Git - thirdparty/gcc.git/commit
gimple-fold/fab: Move ASSUME_ALIGNED handling to gimple-fold [PR121762]
authorAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Sat, 20 Sep 2025 03:58:31 +0000 (20:58 -0700)
committerAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Wed, 24 Sep 2025 17:45:31 +0000 (10:45 -0700)
commit966cdec2b23b8049c263e2239a3da38937ae01d2
treedfe3086bec0791ee5a6803944b9972bffe844b76
parent0088e4a419eb5cc3563a8b4b90fe71f0e33a9a84
gimple-fold/fab: Move ASSUME_ALIGNED handling to gimple-fold [PR121762]

This is the next patch in the series of removing fab.
This one is simplier than builtin_constant_p because the only
time we want to simplify this builtin is at the final folding step.

Note align-5.c needs to change slightly as __builtin_assume_aligned
is no longer taken into account for the same reason as why PR 111875
is closed as invalid and why the testcase is failing at -Og
I added a new testcase align-5a.c where the pointer is explictly aligned
so that the check is gone there.
Note __builtin_assume_aligned should really be instrumented for UBSAN,
I filed PR 122038 for that.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/121762
gcc/ChangeLog:

* gimple-fold.cc (gimple_fold_builtin_assume_aligned): New function.
(gimple_fold_builtin): Call gimple_fold_builtin_assume_aligned
for BUILT_IN_ASSUME_ALIGNED.
* tree-ssa-ccp.cc (pass_fold_builtins::execute): Remove handling
of BUILT_IN_ASSUME_ALIGNED.

gcc/testsuite/ChangeLog:

* c-c++-common/ubsan/align-5.c: Update as __builtin_assume_aligned
is no longer taked into account.
* c-c++-common/ubsan/align-5a.c: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
gcc/gimple-fold.cc
gcc/testsuite/c-c++-common/ubsan/align-5.c
gcc/testsuite/c-c++-common/ubsan/align-5a.c [new file with mode: 0644]
gcc/tree-ssa-ccp.cc