From patchwork Wed Aug 21 13:36:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1974959 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=H59BVaP5; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=tD6NSvtH; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=H59BVaP5; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=tD6NSvtH; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WpnSb6nNhz1yYZ for ; Wed, 21 Aug 2024 23:37:16 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A1FED386F478 for ; Wed, 21 Aug 2024 13:37:07 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by sourceware.org (Postfix) with ESMTPS id 1A502385DC3C for ; Wed, 21 Aug 2024 13:36:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1A502385DC3C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1A502385DC3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724247411; cv=none; b=mc3j7wWq67B1/COoVBFBRZTgZld0q8ncQHS0WMo+hVjc1ToaOPOe2X62CNJIfLXOWL+G13jAnfX1inMCSjdWGqDh7NmkCjjxQmAT9PavIAU2hKYa/pXwMJ5vdsWmE4oF3v1UPHi6KmOXv6pTtUkgH82NtFKewowHDUJ/ai+5sk8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724247411; c=relaxed/simple; bh=5g9YNUlSsgiA/dmtiPOpNE0A34ZFDL2I08HD3IMnwrc=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version; b=dpP4lnctIfm9XDWHs/DoEhSqjy5uL8s6HFFPLoziKY0F0cHzlvTHs93ct5TowcvWo640YkLuMMXMgGFUyvDoKMVggvBoDscGF4PSM7T5gaLiwNJGPdc3WzXJmo5ekf6NjDQ1Qz755Y9PuVFEXnTQFloS6HEOgJly9FrDDV2lzfw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from murzim.nue2.suse.org (unknown [10.168.4.243]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 20289222D5 for ; Wed, 21 Aug 2024 13:36:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1724247408; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=VP/6Gl2oQXRo5OBI4UvpmO+0AIWR8riNdZkQF1ann6E=; b=H59BVaP5JQh02pgsCsMwhn7PSWLLBs57fUmErCHDkstF2pDd8zjRdtCOPSMqnHQMAgDnBg y1SczOIWOjTifHLz4crb0VUVL+tBxeuzn8ca/CPWYIol2YmNue8G8Bx6heBWeN/PhMpcWt Z5cn6O9a2vhnYVNoYdISOnLAs1dk4jw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1724247408; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=VP/6Gl2oQXRo5OBI4UvpmO+0AIWR8riNdZkQF1ann6E=; b=tD6NSvtHbZ3kJQTUEE0lWAe14+QsMQq38S6l7jtXybQzzE9Nask7rG7Eh3q89jxvWCm0GA kYYDT1sH1KCU6pCA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1724247408; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=VP/6Gl2oQXRo5OBI4UvpmO+0AIWR8riNdZkQF1ann6E=; b=H59BVaP5JQh02pgsCsMwhn7PSWLLBs57fUmErCHDkstF2pDd8zjRdtCOPSMqnHQMAgDnBg y1SczOIWOjTifHLz4crb0VUVL+tBxeuzn8ca/CPWYIol2YmNue8G8Bx6heBWeN/PhMpcWt Z5cn6O9a2vhnYVNoYdISOnLAs1dk4jw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1724247408; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=VP/6Gl2oQXRo5OBI4UvpmO+0AIWR8riNdZkQF1ann6E=; b=tD6NSvtHbZ3kJQTUEE0lWAe14+QsMQq38S6l7jtXybQzzE9Nask7rG7Eh3q89jxvWCm0GA kYYDT1sH1KCU6pCA== Date: Wed, 21 Aug 2024 15:36:48 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/116406 - ICE with int<->float punning prevention MIME-Version: 1.0 X-Spam-Score: -1.12 X-Spamd-Result: default: False [-1.12 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MISSING_MID(2.50)[]; NEURAL_HAM_LONG(-0.32)[-0.320]; NEURAL_HAM_SHORT(-0.20)[-0.998]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_ONE(0.00)[1]; RCVD_COUNT_ZERO(0.00)[0]; ARC_NA(0.00)[]; MISSING_XM_UA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_NONE(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[] X-Spam-Level: X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MISSING_MID, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Message-Id: <20240821133707.A1FED386F478@sourceware.org> The following does away with the idea to use non-symmetrical testing of mode_can_transfer_bits in hash-table equality testing. It isn't feasible to always control query order to maintain consistency. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR tree-optimization/116406 * tree-ssa-sccvn.cc (vn_reference_eq): Never equate float and int when the float mode cannot transfer bits. Do not try to anticipate which is the mode we actually load from. * gcc.dg/tree-ssa/pr116406.c: New testcase. * gcc.dg/tree-ssa/ssa-pre-30.c: On x86 dd -msse -mfpmath=sse. --- gcc/testsuite/gcc.dg/tree-ssa/pr116406.c | 21 +++++++++++++++++++++ gcc/testsuite/gcc.dg/tree-ssa/ssa-pre-30.c | 1 + gcc/tree-ssa-sccvn.cc | 3 ++- 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr116406.c diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr116406.c b/gcc/testsuite/gcc.dg/tree-ssa/pr116406.c new file mode 100644 index 00000000000..6643c49218f --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr116406.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-Os -finstrument-functions-once" } */ +/* { dg-additional-options "-mfpmath=387" { target { x86_64-*-* i?86-*-* } } } */ + +typedef union { + float f32; + double f64; + long i64; +} U; + +_Bool +foo (int c, U u) +{ + switch (c) + { + case 1: + return u.f32 - u.f64; + case 0: + return u.i64; + } +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-pre-30.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-pre-30.c index cf9317372d6..29dc1812338 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-pre-30.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-pre-30.c @@ -1,6 +1,7 @@ /* { dg-do compile } */ /* { dg-require-effective-target int32 } */ /* { dg-options "-O2 -fdump-tree-pre-details" } */ +/* { dg-additional-options "-msse -mfpmath=sse" { target { x86_64-*-* i?86-*-* } } } */ int f; int g; diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc index 4370d09d9d8..abf7d38d15c 100644 --- a/gcc/tree-ssa-sccvn.cc +++ b/gcc/tree-ssa-sccvn.cc @@ -838,7 +838,8 @@ vn_reference_eq (const_vn_reference_t const vr1, const_vn_reference_t const vr2) return false; } else if (TYPE_MODE (vr1->type) != TYPE_MODE (vr2->type) - && !mode_can_transfer_bits (TYPE_MODE (vr1->type))) + && (!mode_can_transfer_bits (TYPE_MODE (vr1->type)) + || !mode_can_transfer_bits (TYPE_MODE (vr2->type)))) return false; i = 0;