From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1984) id 9DC893858404; Wed, 18 Oct 2023 08:54:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9DC893858404 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1697619290; bh=HVMoJA5CRXLJt9Lv2bTFfLT56kNruGPlzNKHQ/3vBk0=; h=From:To:Subject:Date:From; b=qJyRp+PSloytqMA3ZDcCtLnZW702ogz6vFfjltJh0Z5CqYfh2Ohz0ADtydBXi20lo dBBwnpn0Qx3JwTMRFWcmjxecR8X7Slv5oWMpJP/Ajfso++4lZaVAdKFVZgBJ/ZRic4 DuRDAtowx+nKXftSLN5B7RmypcBpVnmUQH9EOB/E= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Tamar Christina To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-4714] middle-end: ifcvt: Allow any const IFN in conditional blocks X-Act-Checkin: gcc X-Git-Author: Tamar Christina X-Git-Refname: refs/heads/master X-Git-Oldrev: 4b39aeef594f311e2c1715f15608f1d7ebc2d868 X-Git-Newrev: b0fe8f2f960d746e61debd61655f231f503bccaa Message-Id: <20231018085450.9DC893858404@sourceware.org> Date: Wed, 18 Oct 2023 08:54:50 +0000 (GMT) List-Id: https://gcc.gnu.org/g:b0fe8f2f960d746e61debd61655f231f503bccaa commit r14-4714-gb0fe8f2f960d746e61debd61655f231f503bccaa Author: Tamar Christina Date: Wed Oct 18 09:33:30 2023 +0100 middle-end: ifcvt: Allow any const IFN in conditional blocks When ifcvt was initially added masking was not a thing and as such it was rather conservative in what it supported. For builtins it only allowed C99 builtin functions which it knew it can fold away. These days the vectorizer is able to deal with needing to mask IFNs itself. vectorizable_call is able vectorize the IFN by emitting a VEC_PERM_EXPR after the operation to emulate the masking. This is then used by match.pd to conver the IFN into a masked variant if it's available. For these reasons the restriction in ifconvert is no longer require and we needless block vectorization when we can effectively handle the operations. Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. Note: This patch is part of a testseries and tests for it are added in the AArch64 patch that adds supports for the optab. gcc/ChangeLog: PR tree-optimization/109154 * tree-if-conv.cc (if_convertible_stmt_p): Allow any const IFN. Diff: --- gcc/tree-if-conv.cc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/gcc/tree-if-conv.cc b/gcc/tree-if-conv.cc index 3b4238831c3e..edce842db940 100644 --- a/gcc/tree-if-conv.cc +++ b/gcc/tree-if-conv.cc @@ -1107,17 +1107,21 @@ if_convertible_stmt_p (gimple *stmt, vec refs) case GIMPLE_CALL: { + /* There are some IFN_s that are used to replace builtins but have the + same semantics. Even if MASK_CALL cannot handle them vectorable_call + will insert the proper selection, so do not block conversion. */ + int flags = gimple_call_flags (stmt); + if ((flags & ECF_CONST) + && !(flags & ECF_LOOPING_CONST_OR_PURE) + && gimple_call_combined_fn (stmt) != CFN_LAST) + return true; + tree fndecl = gimple_call_fndecl (stmt); if (fndecl) { /* We can vectorize some builtins and functions with SIMD "inbranch" clones. */ - int flags = gimple_call_flags (stmt); struct cgraph_node *node = cgraph_node::get (fndecl); - if ((flags & ECF_CONST) - && !(flags & ECF_LOOPING_CONST_OR_PURE) - && fndecl_built_in_p (fndecl)) - return true; if (node && node->simd_clones != NULL) /* Ensure that at least one clone can be "inbranch". */ for (struct cgraph_node *n = node->simd_clones; n != NULL; @@ -1129,6 +1133,7 @@ if_convertible_stmt_p (gimple *stmt, vec refs) return true; } } + return false; }