From patchwork Wed Jan 31 08:44:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 85070 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1E0343858006 for ; Wed, 31 Jan 2024 08:49:55 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 9615638582A1 for ; Wed, 31 Jan 2024 08:44:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9615638582A1 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9615638582A1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706690673; cv=none; b=TRFepKgy3jJxaERCIHCbaAqtV/kqt5lay1MDODK6omh7XddaaMmJf2HKbjbW0IQpL61cum4DnBtExWgfudOTh1t8cDKSNx++5JbchUOuWD2cbKifMI2/Fmk4yutAfT8ckEz4risp7SUO59tJB91jFfGVLPtZHyIyNqQz93ohcUY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706690673; c=relaxed/simple; bh=4VfA0Yt3+4IIsRRo1hei2OCtYVgoLU6Nl71T30//FpM=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=wqtMvLvQuwbFpQcbje/O0qUlZ2kNLJx5r76UNgsLvflgxP/FyyYeAGuWOrEmK0iCnCA0F8V+BUe7r8hjL8rQH0jAkrlFhSaDPtqTvYSedYJuZ0h8PMYt2cj5639XDFTfszlhOzYmJqrQOoKmU6v1hzsXK6fGCGy1YFqK9sIlhFI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706690665; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=CGz39W9GgzgCXXpqMpeqZ4aYG8BuIX2ljFA5zyIssHM=; b=ci/UdeXAJi53X3uex07GqgeaZ4xaZGkZ5Hx+yshRyIV5tWTAa9gtGpaYsTIJOW5tHcOWJ8 FxpehTRhq2w7YiIAfzRhu1SZRI/1NHI2oOqbkHdsyYndfhOc3260ZK94U4zq1DG3OCZO2d GzV5A3nfT0ALXk140K61yOT3pLZy2RU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-677-Ae9m3-BUNFu0cFG5koYfSQ-1; Wed, 31 Jan 2024 03:44:22 -0500 X-MC-Unique: Ae9m3-BUNFu0cFG5koYfSQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E8B9794632D; Wed, 31 Jan 2024 08:44:21 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.70]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 799311C060AF; Wed, 31 Jan 2024 08:44:21 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 40V8iIF5267029 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 09:44:18 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 40V8iG2U267028; Wed, 31 Jan 2024 09:44:16 +0100 Date: Wed, 31 Jan 2024 09:44:16 +0100 From: Jakub Jelinek To: Richard Biener , Eric Botcazou , Segher Boessenkool , Jeff Law Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] simplify-rtx: Fix up last argument to simplify_gen_unary [PR113656] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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: , Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Hi! When simplifying e.g. (float_truncate:SF (float_truncate:DF (reg:XF)) or (float_truncate:SF (float_extend:XF (reg:DF)) etc. into (float_truncate:SF (reg:XF)) or (float_truncate:SF (reg:DF)) we call simplify_gen_unary with incorrect op_mode argument, it should be the argument's mode, but we call it with the outer mode instead. As these are all floating point operations, the argument always has non-VOIDmode and so we can just use that mode (as done in similar simplifications a few lines later), but neither FLOAT_TRUNCATE nor FLOAT_EXTEND are operations that should have the same modes of operand and result. This bug hasn't been a problem for years because normally op_mode is used only if the mode of op is VOIDmode, otherwise it is redundant, but r10-2139 added an assertion in some spots that op_mode is right even in such cases. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2024-01-31 Jakub Jelinek PR rtl-optimization/113656 * simplify-rtx.cc (simplify_context::simplify_unary_operation_1) : Fix up last argument to simplify_gen_unary. * gcc.target/i386/pr113656.c: New test. Jakub --- gcc/simplify-rtx.cc.jj 2024-01-03 11:51:32.828713189 +0100 +++ gcc/simplify-rtx.cc 2024-01-30 19:34:30.516934480 +0100 @@ -1305,7 +1305,7 @@ simplify_context::simplify_unary_operati > GET_MODE_UNIT_SIZE (mode) ? FLOAT_TRUNCATE : FLOAT_EXTEND, mode, - XEXP (op, 0), mode); + XEXP (op, 0), GET_MODE (XEXP (op, 0))); /* (float_truncate (float x)) is (float x) */ if ((GET_CODE (op) == FLOAT || GET_CODE (op) == UNSIGNED_FLOAT) --- gcc/testsuite/gcc.target/i386/pr113656.c.jj 2024-01-30 19:38:29.029608721 +0100 +++ gcc/testsuite/gcc.target/i386/pr113656.c 2024-01-30 19:37:10.519703443 +0100 @@ -0,0 +1,12 @@ +/* PR rtl-optimization/113656 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -frounding-math -funsafe-math-optimizations -mavx512fp16 -mavx512vl" } */ + +_Float16 a[8]; + +void +foo () +{ + for (int i = 0; i < 8; i++) + a[i] = i - 8.4; +}