From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 00C9F3858C5E; Thu, 23 Feb 2023 10:10:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 00C9F3858C5E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id C63EE5D32B; Thu, 23 Feb 2023 10:10:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1677147014; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=7AGtuADV8N7SFe9aL+pH9bDwvFiIuSd9H7+V5BZoHvg=; b=2W3rtsFWsbKGY1yrxzEfAzsBfUuDKYyPemlyu+deubpXJUBu5MHEfanVQg8ZeJSQCAWBRe AufFiI2uGx3om0cnMhZUfpg78ISxT9M9AxmDOZeGqDek0Y9V8D7aSQ1+iK9VS1sB7XGi0n PKH4L8l8u3R65o3wQwgs7AA5M4crOOw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1677147014; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=7AGtuADV8N7SFe9aL+pH9bDwvFiIuSd9H7+V5BZoHvg=; b=3ZQLCq+y49esyigf3AGvwhREeevWBaaI9bLYWggT/4l6hajaJwLCaLYZyoeTCEtopiupqO hMD9BjtPsjLBt3DA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id B2D2E13928; Thu, 23 Feb 2023 10:10:14 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id W5qtKoY792OkAgAAMHmgww (envelope-from ); Thu, 23 Feb 2023 10:10:14 +0000 Date: Thu, 23 Feb 2023 11:10:14 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org cc: ams@gcc.gnu.org Subject: [PATCH] tree-optimization/108888 - call if-conversion MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Message-Id: <20230223101014.B2D2E13928@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: The following makes sure to only predicate calls necessary. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR tree-optimization/108888 * tree-if-conv.cc (if_convertible_stmt_p): Set PLF_2 on calls to predicate. (predicate_statements): Only predicate calls with PLF_2. * g++.dg/torture/pr108888.C: New testcase. --- gcc/testsuite/g++.dg/torture/pr108888.C | 18 ++++++++++++++++++ gcc/tree-if-conv.cc | 17 ++++++++++------- 2 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/g++.dg/torture/pr108888.C diff --git a/gcc/testsuite/g++.dg/torture/pr108888.C b/gcc/testsuite/g++.dg/torture/pr108888.C new file mode 100644 index 00000000000..29a22e21102 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr108888.C @@ -0,0 +1,18 @@ +// { dg-do compile } + +int scaleValueSaturate_scalefactor, scaleValueSaturate___trans_tmp_2, + scaleValuesSaturate_i; +int scaleValueSaturate(int value) { + int result = __builtin_clz(value); + if (value) + if (-result <= scaleValueSaturate_scalefactor) + return 0; + return scaleValueSaturate___trans_tmp_2; +} +short scaleValuesSaturate_dst; +short *scaleValuesSaturate_src; +void scaleValuesSaturate() { + for (; scaleValuesSaturate_i; scaleValuesSaturate_i++) + scaleValuesSaturate_dst = + scaleValueSaturate(scaleValuesSaturate_src[scaleValuesSaturate_i]); +} diff --git a/gcc/tree-if-conv.cc b/gcc/tree-if-conv.cc index a7a8406374d..0e384e36394 100644 --- a/gcc/tree-if-conv.cc +++ b/gcc/tree-if-conv.cc @@ -1099,6 +1099,7 @@ if_convertible_stmt_p (gimple *stmt, vec refs) n = n->simdclone->next_clone) if (n->simdclone->inbranch) { + gimple_set_plf (stmt, GF_PLF_2, true); need_to_predicate = true; return true; } @@ -2541,7 +2542,8 @@ predicate_statements (loop_p loop) release_defs (stmt); continue; } - else if (gimple_plf (stmt, GF_PLF_2)) + else if (gimple_plf (stmt, GF_PLF_2) + && is_gimple_assign (stmt)) { tree lhs = gimple_assign_lhs (stmt); tree mask; @@ -2625,13 +2627,14 @@ predicate_statements (loop_p loop) gimple_assign_set_rhs1 (stmt, ifc_temp_var (type, rhs, &gsi)); update_stmt (stmt); } - - /* Convert functions that have a SIMD clone to IFN_MASK_CALL. This - will cause the vectorizer to match the "in branch" clone variants, - and serves to build the mask vector in a natural way. */ - gcall *call = dyn_cast (gsi_stmt (gsi)); - if (call && !gimple_call_internal_p (call)) + else if (gimple_plf (stmt, GF_PLF_2) + && is_gimple_call (stmt)) { + /* Convert functions that have a SIMD clone to IFN_MASK_CALL. + This will cause the vectorizer to match the "in branch" + clone variants, and serves to build the mask vector + in a natural way. */ + gcall *call = dyn_cast (gsi_stmt (gsi)); tree orig_fn = gimple_call_fn (call); int orig_nargs = gimple_call_num_args (call); auto_vec args; -- 2.35.3