From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1611) id 828F63858D28; Tue, 30 Nov 2021 17:45:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 828F63858D28 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Martin Jambor To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-5633] ipa-sra: Check also ECF_LOOPING_CONST_OR_PURE when evaluating calls X-Act-Checkin: gcc X-Git-Author: Martin Jambor X-Git-Refname: refs/heads/master X-Git-Oldrev: 7057b8f8c2fbb7a2112705c2962d92b8ccef7c30 X-Git-Newrev: e5440bc08e07fd491dcccd47e1b86a5985ee117c Message-Id: <20211130174550.828F63858D28@sourceware.org> Date: Tue, 30 Nov 2021 17:45:50 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Nov 2021 17:45:50 -0000 https://gcc.gnu.org/g:e5440bc08e07fd491dcccd47e1b86a5985ee117c commit r12-5633-ge5440bc08e07fd491dcccd47e1b86a5985ee117c Author: Martin Jambor Date: Tue Nov 30 18:45:11 2021 +0100 ipa-sra: Check also ECF_LOOPING_CONST_OR_PURE when evaluating calls in PR 103267 Honza found out that IPA-SRA does not look at ECF_LOOPING_CONST_OR_PURE when evaluating if a call can have side effects. Fixed with this patch. The testcase infinitely loops in a const function, so it would not make a good addition to the testsuite. gcc/ChangeLog: 2021-11-29 Martin Jambor PR ipa/103267 * ipa-sra.c (scan_function): Also check ECF_LOOPING_CONST_OR_PURE flag. Diff: --- gcc/ipa-sra.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/ipa-sra.c b/gcc/ipa-sra.c index cb0e30507a1..12ccd049552 100644 --- a/gcc/ipa-sra.c +++ b/gcc/ipa-sra.c @@ -1925,7 +1925,8 @@ scan_function (cgraph_node *node, struct function *fun) if (lhs) scan_expr_access (lhs, stmt, ISRA_CTX_STORE, bb); int flags = gimple_call_flags (stmt); - if ((flags & (ECF_CONST | ECF_PURE)) == 0) + if (((flags & (ECF_CONST | ECF_PURE)) == 0) + || (flags & ECF_LOOPING_CONST_OR_PURE)) bitmap_set_bit (final_bbs, bb->index); } break;