From patchwork Wed Jul 31 13:39:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1967114 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=lM/eKU2m; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Y2zQc/Q8; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=lM/eKU2m; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Y2zQc/Q8; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4WYtWR18Nwz1yYq for ; Wed, 31 Jul 2024 23:40:03 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4C819385843B for ; Wed, 31 Jul 2024 13:40:00 +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 [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id 11AC73858282 for ; Wed, 31 Jul 2024 13:39:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 11AC73858282 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 11AC73858282 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722433176; cv=none; b=KlxI6iVDdfQmL3somRn5aXUK/SxhdB6UFH2fnkxEakVGh6TFTM+QfcFfSKolk8IqIoLZ7PtfCmJiBEx5sjqm7UX0vSbdFDFOIuwrJFyTTb/qa9hdqe37EG55y/kcOxNDvP/nItABOAN5SMCAVxJQOIKszy57iwQ02VnfwDMarAs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722433176; c=relaxed/simple; bh=ebBBDLS32TUZtXHI1G1rKKU0OkXSWShW2D0v8FcC7S8=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version; b=ErtEfm2tcxy49ZsxINeUGWPh38u92MyExxMyfVvZCPY19XPmzHExgs0JNbATqrLHs4bKtPnaRKDTr8jE++XW4PdFMABmnaOybKKNPovLZxTsxu8Vf0tAox3l5HsZKznsb6WEpjESU+SXWKPm/i0mUkn1mduHeVc0D/tXYyDOkJ4= 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 2605621A49; Wed, 31 Jul 2024 13:39:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1722433174; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=xYyRVWjxnZsDNjdt3u9o0OGLP4L5bmfyHq05zgA6tOo=; b=lM/eKU2m4YaRnEiGyz55HiZlIa9mehDhflgtg156PTlQ7xj52my3rrCWdlTBiJ1luMKBMK NQEIY95kdH1keA57yWPd+HiDmtUVS/2akic4zf+zkLFeC3RX0JzDrQERbe8JPuFkAaWlpy r8x4WtysOCtZ+yThIhwn+FTjrQN5r7k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1722433174; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=xYyRVWjxnZsDNjdt3u9o0OGLP4L5bmfyHq05zgA6tOo=; b=Y2zQc/Q8flJOg4XaSuCRjOx3CsAD2G0kf4gkcTrtakO02YysODWNILgLdE29H6VMdNvKEd NXXrD0z0OglEG+Aw== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1722433174; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=xYyRVWjxnZsDNjdt3u9o0OGLP4L5bmfyHq05zgA6tOo=; b=lM/eKU2m4YaRnEiGyz55HiZlIa9mehDhflgtg156PTlQ7xj52my3rrCWdlTBiJ1luMKBMK NQEIY95kdH1keA57yWPd+HiDmtUVS/2akic4zf+zkLFeC3RX0JzDrQERbe8JPuFkAaWlpy r8x4WtysOCtZ+yThIhwn+FTjrQN5r7k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1722433174; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=xYyRVWjxnZsDNjdt3u9o0OGLP4L5bmfyHq05zgA6tOo=; b=Y2zQc/Q8flJOg4XaSuCRjOx3CsAD2G0kf4gkcTrtakO02YysODWNILgLdE29H6VMdNvKEd NXXrD0z0OglEG+Aw== Date: Wed, 31 Jul 2024 15:39:34 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org cc: richard.sandiford@arm.com, paulkoning@comcast.net Subject: [PATCH 1/3][v3] Add TARGET_MODE_CAN_TRANSFER_BITS MIME-Version: 1.0 X-Spamd-Result: default: False [-1.60 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MISSING_MID(2.50)[]; NEURAL_HAM_LONG(-1.00)[-0.998]; MIME_GOOD(-0.10)[text/plain]; RCVD_COUNT_ZERO(0.00)[0]; FREEMAIL_ENVRCPT(0.00)[comcast.net]; MISSING_XM_UA(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FREEMAIL_CC(0.00)[arm.com,comcast.net]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; TO_DN_NONE(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_THREE(0.00)[3] X-Spam-Level: X-Spam-Score: -1.60 X-Spam-Status: No, score=-10.5 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 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: <20240731134000.4C819385843B@sourceware.org> The following adds a target hook to specify whether regs of MODE can be used to transfer bits. The hook is supposed to be used for value-numbering to decide whether a value loaded in such mode can be punned to another mode instead of re-loading the value in the other mode and for SRA to decide whether MODE is suitable as container holding a value to be used in different modes. Adjusted documentation in v3. * target.def (mode_can_transfer_bits): New target hook. * target.h (mode_can_transfer_bits): New function wrapping the hook and providing default behavior. * doc/tm.texi.in: Update. * doc/tm.texi: Re-generate. --- gcc/doc/tm.texi | 11 +++++++++++ gcc/doc/tm.texi.in | 2 ++ gcc/target.def | 13 +++++++++++++ gcc/target.h | 16 ++++++++++++++++ 4 files changed, 42 insertions(+) diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index c7535d07f4d..cc33084ed32 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -4545,6 +4545,17 @@ is either a declaration of type int or accessed by dereferencing a pointer to int. @end deftypefn +@deftypefn {Target Hook} bool TARGET_MODE_CAN_TRANSFER_BITS (machine_mode @var{mode}) +Define this to return false if the mode @var{mode} cannot be used +for memory copying of @code{GET_MODE_SIZE (mode)} units. This might be +because a register class allowed for @var{mode} has registers that do +not transparently transfer every bit pattern or because the load or +store patterns available for @var{mode} have this issue. + +The default is to assume modes with the same precision as size are fine +to be used. +@end deftypefn + @deftypefn {Target Hook} machine_mode TARGET_TRANSLATE_MODE_ATTRIBUTE (machine_mode @var{mode}) Define this hook if during mode attribute processing, the port should translate machine_mode @var{mode} to another mode. For example, rs6000's diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index 64cea3b1eda..8af3f414505 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -3455,6 +3455,8 @@ stack. @hook TARGET_REF_MAY_ALIAS_ERRNO +@hook TARGET_MODE_CAN_TRANSFER_BITS + @hook TARGET_TRANSLATE_MODE_ATTRIBUTE @hook TARGET_SCALAR_MODE_SUPPORTED_P diff --git a/gcc/target.def b/gcc/target.def index 3de1aad4c84..1d0ea6f30ca 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -3363,6 +3363,19 @@ a pointer to int.", bool, (ao_ref *ref), default_ref_may_alias_errno) +DEFHOOK +(mode_can_transfer_bits, + "Define this to return false if the mode @var{mode} cannot be used\n\ +for memory copying of @code{GET_MODE_SIZE (mode)} units. This might be\n\ +because a register class allowed for @var{mode} has registers that do\n\ +not transparently transfer every bit pattern or because the load or\n\ +store patterns available for @var{mode} have this issue.\n\ +\n\ +The default is to assume modes with the same precision as size are fine\n\ +to be used.", + bool, (machine_mode mode), + NULL) + /* Support for named address spaces. */ #undef HOOK_PREFIX #define HOOK_PREFIX "TARGET_ADDR_SPACE_" diff --git a/gcc/target.h b/gcc/target.h index c1f99b97b86..837651d273a 100644 --- a/gcc/target.h +++ b/gcc/target.h @@ -312,6 +312,22 @@ estimated_poly_value (poly_int64 x, return targetm.estimated_poly_value (x, kind); } +/* Return true when MODE can be used to copy GET_MODE_BITSIZE bits + unchanged. */ + +inline bool +mode_can_transfer_bits (machine_mode mode) +{ + if (mode == BLKmode) + return true; + if (maybe_ne (GET_MODE_BITSIZE (mode), + GET_MODE_UNIT_PRECISION (mode) * GET_MODE_NUNITS (mode))) + return false; + if (targetm.mode_can_transfer_bits) + return targetm.mode_can_transfer_bits (mode); + return true; +} + #ifdef GCC_TM_H #ifndef CUMULATIVE_ARGS_MAGIC From patchwork Wed Jul 31 13:40:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1967116 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=tVk49GhC; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=kgCXEZU4; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=tVk49GhC; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=kgCXEZU4; 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 4WYtXB4YMMz1ybb for ; Wed, 31 Jul 2024 23:40:42 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DFDDB385843B for ; Wed, 31 Jul 2024 13:40:40 +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 4045A3857011 for ; Wed, 31 Jul 2024 13:40:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4045A3857011 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 4045A3857011 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=1722433217; cv=none; b=NIPM0tTLiJJIxdBWbJoOCvF3PvcI6Se8sfHpcHTBGLSHbDCgQsBlJ4soUs2LFhoWnqGgQSySTFzUX4surt2vLwDT50jZhin3HR7YK47hAS1hiO0Kwb8Qc7iYocPLd8QBQ61Ol/vdc9c2J+P8TLPgYabawojGdvwbAVYESXEp/gg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722433217; c=relaxed/simple; bh=XxvsaSPONuxn3HvzGET1yDZNlRLMXyUrqfOfVT/tq64=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version; b=Q3ija0PABCVH75W8Ctf3fGLzyMqTtXkCpA7SbjvGADJpfT7n4i62j+EXiyb/tGw8RrksktPJb611xMfM1HmTsIOs+y0A7NmDmmBJr3gvmDgV/iyQmxqA6J46ZhVrrzRKOhtXbzK2g2mPCk1S4TqH8YjsCBcWjQ2VChyo2ODnVJ8= 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 3E58E21A49 for ; Wed, 31 Jul 2024 13:40:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1722433215; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=Z48KjIfMPCphxvnFKXbkmMeiuhVwpkXgGkIakhDGyYo=; b=tVk49GhC/xhE79xnivgAa67PCatJBIW46beRLG1QSOBVFcq5rpWiW5QPW9OCN2fZtYb2Yk AXtRc6RTjHZ/+RI0uT/DAs2nYvNNrSy+YhOo8nWYOT+qb8IJuppIpY/bt0Vn6K/XvMfxXp 1JcL3xhxSnxtUyFHqsxqI59ihaf4h5I= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1722433215; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=Z48KjIfMPCphxvnFKXbkmMeiuhVwpkXgGkIakhDGyYo=; b=kgCXEZU4nsmv7S1NZGz/yHqXXTAnqIJ1L9U/LJeEAdzqiU1zmTuCvkSme9VncdGMS/zBQY xTG1G2sOsJ9NiIBA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1722433215; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=Z48KjIfMPCphxvnFKXbkmMeiuhVwpkXgGkIakhDGyYo=; b=tVk49GhC/xhE79xnivgAa67PCatJBIW46beRLG1QSOBVFcq5rpWiW5QPW9OCN2fZtYb2Yk AXtRc6RTjHZ/+RI0uT/DAs2nYvNNrSy+YhOo8nWYOT+qb8IJuppIpY/bt0Vn6K/XvMfxXp 1JcL3xhxSnxtUyFHqsxqI59ihaf4h5I= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1722433215; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=Z48KjIfMPCphxvnFKXbkmMeiuhVwpkXgGkIakhDGyYo=; b=kgCXEZU4nsmv7S1NZGz/yHqXXTAnqIJ1L9U/LJeEAdzqiU1zmTuCvkSme9VncdGMS/zBQY xTG1G2sOsJ9NiIBA== Date: Wed, 31 Jul 2024 15:40:15 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH 3/3][v3] tree-optimization/114659 - VN and FP to int punning MIME-Version: 1.0 X-Spamd-Result: default: False [-1.06 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MISSING_MID(2.50)[]; NEURAL_HAM_LONG(-0.46)[-0.457]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_ONE(0.00)[1]; ARC_NA(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_COUNT_ZERO(0.00)[0]; MISSING_XM_UA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; TO_DN_NONE(0.00)[]; MIME_TRACE(0.00)[0:+] X-Spam-Level: X-Spam-Score: -1.06 X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, MISSING_MID, 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 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: <20240731134040.DFDDB385843B@sourceware.org> The following addresses another case where x87 FP loads mangle the bit representation and thus are not suitable for a representative in other types. VN was value-numbering a later integer load of 'x' as the same as a former float load of 'x'. We can use the new TARGET_MODE_CAN_TRANSFER_BITS hook to identify problematic modes and enforce strict compatibility for those in the reference comparison, improving the handling of modes with padding in visit_reference_op_load. PR tree-optimization/114659 * tree-ssa-sccvn.cc (visit_reference_op_load): Do not prevent punning from modes with padding here, but ... (vn_reference_eq): ... ensure this here, also honoring types with modes that cannot act as bit container. * gcc.target/i386/pr114659.c: New testcase. --- gcc/testsuite/gcc.target/i386/pr114659.c | 62 ++++++++++++++++++++++++ gcc/tree-ssa-sccvn.cc | 11 ++--- 2 files changed, 66 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr114659.c diff --git a/gcc/testsuite/gcc.target/i386/pr114659.c b/gcc/testsuite/gcc.target/i386/pr114659.c new file mode 100644 index 00000000000..e1e24d55687 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr114659.c @@ -0,0 +1,62 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +int +my_totalorderf (float const *x, float const *y) +{ + int xs = __builtin_signbit (*x); + int ys = __builtin_signbit (*y); + if (!xs != !ys) + return xs; + + int xn = __builtin_isnan (*x); + int yn = __builtin_isnan (*y); + if (!xn != !yn) + return !xn == !xs; + if (!xn) + return *x <= *y; + + unsigned int extended_sign = -!!xs; + union { unsigned int i; float f; } xu = {0}, yu = {0}; + __builtin_memcpy (&xu.f, x, sizeof (float)); + __builtin_memcpy (&yu.f, y, sizeof (float)); + return (xu.i ^ extended_sign) <= (yu.i ^ extended_sign); +} + +static float +positive_NaNf () +{ + float volatile nan = 0.0f / 0.0f; + return (__builtin_signbit (nan) ? - nan : nan); +} + +typedef union { float value; unsigned int word[1]; } memory_float; + +static memory_float +construct_memory_SNaNf (float quiet_value) +{ + memory_float m; + m.value = quiet_value; + m.word[0] ^= (unsigned int) 1 << 22; + m.word[0] |= (unsigned int) 1; + return m; +} + +memory_float x[7] = + { + { 0 }, + { 1e-5 }, + { 1 }, + { 1e37 }, + { 1.0f / 0.0f }, + }; + +int +main () +{ + x[5] = construct_memory_SNaNf (positive_NaNf ()); + x[6] = (memory_float) { positive_NaNf () }; + if (! my_totalorderf (&x[5].value, &x[6].value)) + __builtin_abort (); + return 0; +} diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc index dc377fa16ce..0639ba426ff 100644 --- a/gcc/tree-ssa-sccvn.cc +++ b/gcc/tree-ssa-sccvn.cc @@ -837,6 +837,9 @@ vn_reference_eq (const_vn_reference_t const vr1, const_vn_reference_t const vr2) TYPE_VECTOR_SUBPARTS (vr2->type))) return false; } + else if (TYPE_MODE (vr1->type) != TYPE_MODE (vr2->type) + && !mode_can_transfer_bits (TYPE_MODE (vr1->type))) + return false; i = 0; j = 0; @@ -5814,13 +5817,7 @@ visit_reference_op_load (tree lhs, tree op, gimple *stmt) if (result && !useless_type_conversion_p (TREE_TYPE (result), TREE_TYPE (op))) { - /* Avoid the type punning in case the result mode has padding where - the op we lookup has not. */ - if (TYPE_MODE (TREE_TYPE (result)) != BLKmode - && maybe_lt (GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (result))), - GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (op))))) - result = NULL_TREE; - else if (CONSTANT_CLASS_P (result)) + if (CONSTANT_CLASS_P (result)) result = const_unop (VIEW_CONVERT_EXPR, TREE_TYPE (op), result); else {