]> git.ipfire.org Git - thirdparty/gcc.git/commit
fab/gimple-fold: Move __builtin_constant_p folding to gimple-fold [PR121762]
authorAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Fri, 19 Sep 2025 21:37:04 +0000 (14:37 -0700)
committerAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Mon, 22 Sep 2025 15:44:40 +0000 (08:44 -0700)
commit8a6598f4a24306c8aae62c4a591d709a0d1abbc6
treef477639fe4554f793fe37a895bdf0157a0cebbbd
parentdc38eaf935a9408707bb96d218fc3f99169d4d48
fab/gimple-fold: Move __builtin_constant_p folding to gimple-fold [PR121762]

This is the first patch in removing fold_all_builtins pass.
We want to fold __builtin_constant_p into 0 if we know the argument can't be
a constant. So currently that is done in fab pass (though ranger handles it now too).
Instead of having fab do it we can check PROP_last_full_fold if set and set it
to 0 instead.

Note for -Og, fab was the only place which did this conversion, so we need to
set PROP_last_full_fold for it; later on fab will be removed and isel will do
it instead but that is for another day.

Also instead of going through fold_call_stmt to call fold_builtin_constant_p,
fold_builtin_constant_p is called directly from gimple_fold_builtin_constant_p.
This should speed up the compiling slight :).

Note fab was originally added to do this transformation during the development
of the ssa branch.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/121762
gcc/ChangeLog:

* builtins.cc (fold_builtin_constant_p): Make non-static.
* builtins.h (fold_builtin_constant_p): New declaration.
* gimple-fold.cc (gimple_fold_builtin_constant_p): New function.
(gimple_fold_builtin): Call gimple_fold_builtin_constant_p
for BUILT_IN_CONSTANT_P.
* tree-ssa-ccp.cc (pass_fold_builtins::execute): Set PROP_last_full_fold
on curr_properties. Remove handling of BUILT_IN_CONSTANT_P.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
gcc/builtins.cc
gcc/builtins.h
gcc/gimple-fold.cc
gcc/tree-ssa-ccp.cc