aarch64: Fold intrinsics even if result is unused.
GCC now folds aarch64 NEON intrinsics even when their results are unused, preventing incorrect code generation.
GCC’s intrinsic folding logic for aarch64 NEON instructions previously skipped folding if the result was unused. This was based on an incorrect assumption that all intrinsics would have an expand implementation. This commit corrects the logic to compute and store the result in a variable, allowing later passes to discard it if truly unused. A new test case verifies this fix.
In Details
The gimple_folder::fold in aarch64's acle-builtins.cc incorrectly bailed out of folding certain intrinsic calls if their results were unused. This assumed that a non-folded call would always have an expand method available to generate RTL. However, NEON intrinsics often only have fold implementations. This change modifies the behavior to compute the result and store it in a temporary, which is then subject to dead code elimination.