]> git.ipfire.org Git - thirdparty/gcc.git/commit
phi-opt: Fix for failing maybe_push_res_to_seq in factor_out_conditional_operation...
authorAndrew Pinski <quic_apinski@quicinc.com>
Mon, 19 Aug 2024 03:45:35 +0000 (20:45 -0700)
committerAndrew Pinski <quic_apinski@quicinc.com>
Tue, 20 Aug 2024 20:26:28 +0000 (13:26 -0700)
commit404d947d8ddd3c3035dcea115e9bab4c4a6bfa1c
tree8e5481bec7ccb28fda6b2b68e8eefd6fcb004656
parentd05949558ef1c8eeeb07399174a64f968f70e3ee
phi-opt: Fix for failing maybe_push_res_to_seq in factor_out_conditional_operation [PR 116409]

The code was assuming that maybe_push_res_to_seq would not fail if the gimple_extract_op returned true.
But for some cases when the function is pure rather than const, then it can fail.
This change moves around the code to check the result of maybe_push_res_to_seq instead of assuming it will
always work.

Changes since v1:
* v2: Instead of directly testing non-pure builtin functions change to test if maybe_push_res_to_seq fails.

Bootstrapped and tested on x86_64-linux-gnu with no regressions.

PR tree-optimization/116409

gcc/ChangeLog:

* tree-ssa-phiopt.cc (factor_out_conditional_operation): Move
maybe_push_res_to_seq before creating the phi node and the debug dump.
Return false if maybe_push_res_to_seq fails.

gcc/testsuite/ChangeLog:

* gcc.dg/torture/pr116409-1.c: New test.
* gcc.dg/torture/pr116409-2.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
gcc/testsuite/gcc.dg/torture/pr116409-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr116409-2.c [new file with mode: 0644]
gcc/tree-ssa-phiopt.cc