https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127771
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Dhruv Chawla <[email protected]>: https://gcc.gnu.org/g:cf7bfcf51fcfaf7af15e72f760d88fa5712a4f88 commit r17-6344-gcf7bfcf51fcfaf7af15e72f760d88fa5712a4f88 Author: Dhruv Chawla <[email protected]> Date: Tue Oct 27 09:29:44 2026 +0000 aarch64: Fix ICE on discarded intrinsic result [PR127771] r17-4816-gb24418a2212866 gives a call whose result is discarded a placeholder lhs using create_tmp_var, which gives a VAR_DECL. This ends up setting ssa_renaming_needed and subsequent passes which fold do not set TODO_update_ssa, so execute_todo ICEs. This is not necessary for aggregate types, so this only requires a check of is_gimple_reg_type. To fix this, this patch makes lhs a member function of the same name, which fills in the destination the first time a fold asks for it and makes it an SSA name for register types. Since lhs is only called by folds that produce a value, a fold that declines no longer leaves a temporary behind. This patch also adds a new ret_type member taken from the function declaration, so that folds no longer have to query the lhs at all. This also allows making the m_lhs member variable private as there are no external references to it anymore. Instead of trying to decide when to drop the call based on side effects, just generate the placeholder and let DCE choose. Bootstrapped and regtested on aarch64-linux-gnu. Signed-off-by: Dhruv Chawla <[email protected]> gcc/ChangeLog: PR target/127771 * config/aarch64/aarch64-acle-builtins.h (build_var): Declare. (gimple_folder::lhs): Change from a member variable to a member function. (gimple_folder::ret_type): New member variable. (gimple_folder::m_lhs): New private member variable. * config/aarch64/aarch64-acle-builtins.cc (build_var): Move here from aarch64-neon-builtins-base.cc and add a comment. (gimple_folder::gimple_folder): Initialize ret_type. (gimple_folder::lhs): New function. (gimple_folder::force_val): Use build_var. (gimple_folder::fold): Do not create a placeholder lhs. (gimple_folder::fold_contiguous_load, gimple_folder::fold_pfalse) (gimple_folder::convert_and_fold, gimple_folder::fold_to_cstu) (gimple_folder::fold_to_ptrue, gimple_folder::fold_to_pfalse) (gimple_folder::fold_to_vl_pred, gimple_folder::fold_const_binary) (gimple_folder::fold_active_lanes_to, gimple_folder::fold_call_to): Use ret_type and lhs. * config/aarch64/aarch64-neon-builtins-base.cc: Likewise. (build_var): Move to aarch64-acle-builtins.cc. * config/aarch64/aarch64-sve-builtins-base.cc: Likewise. * config/aarch64/aarch64-sve-builtins-functions.h: Likewise. * config/aarch64/aarch64-sve-builtins-sve2.cc: Likewise. gcc/testsuite/ChangeLog: PR target/127771 * gcc.target/aarch64/sve/acle/general/pr127771.c: New test.
