From patchwork Sat Oct 21 18:07:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 156485 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp421840vqx; Sat, 21 Oct 2023 11:07:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHiA2JjX4ArSHxWaUTbzitiRpV9c0ViExXD4osTdScUuqvOoF6BxArENitOn4h3zuLJF8/s X-Received: by 2002:a05:622a:1213:b0:407:613a:c383 with SMTP id y19-20020a05622a121300b00407613ac383mr5941648qtx.67.1697911671199; Sat, 21 Oct 2023 11:07:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697911671; cv=pass; d=google.com; s=arc-20160816; b=ZlkK62ITvPjalevHTVKTjzDuuUQYElt9H1LRwrL5qJ2UBFkXiIoCRtKaao5btxWCgd l+qcCKwJwfTYigXmtkDO0LbUs8Tvx0P1bK2l8cTL+Csv0OlGNfeuJpmgSBr+o9mUTCqf anWLquVMe+p0QFJQfwKQ1+ps5oWma1IscVIFqkjN6axXr27RmG3GIUI3Dmb3XSL63ZIc fj6U1rjdMvWHc88KnTZb9mtYwR22pR7hX9iZMQFrt9nFxOnVoPjzKtoNyw/PBvnFpabr b9f2WFPAvf1FtVz1Fa8U4/4zQsx2wmwnOuMfQ/7D9O7Wl9jiuAlwRgcNHQz+Uy7pHEpA z/6w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=UFnd02Bdqj46zap2k8mw8ICe37zHQYQm6n7mv8WidI4=; fh=6xfd3IYC8Zt5CA4TsXZHhPmGMhO9cjo3oiHaQc5bSUI=; b=ttYhD18pYjKWKp6Cy3NGtrcpEOY63Qzv2j06pUVUfFC7e4ftpWLjtcvw2Gb7AYAxtX DhTLsjEOYtReNVXQXKa9ySmehP5zUuTu3RqZjCGqV58FxBnATiSZc0seMoMdakrHT7lw pxoZT9xSVSxd5u+gBEhIqqpXfoWd8LScyIhGsigXwxmI4TdZuiwfD4nr+5jUVJdckSv5 CWwjovcWSFhzzv8G4aiSLbEAXBOdHgIHEnSciBzNIWdqE6zTDzlt44mtD0TdLi0j6O9W NhlHmLDuRUGUNuwaiQYFfWk45AtHmjP/drnqkQg2rWSu6XStNjFjOzSyJ+WsCgQdORlV 6TrQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=UcHo5UFf; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id d12-20020ac85acc000000b00418194af9ecsi3241853qtd.51.2023.10.21.11.07.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Oct 2023 11:07:51 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=UcHo5UFf; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F0685385841B for ; Sat, 21 Oct 2023 18:07:50 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by sourceware.org (Postfix) with ESMTPS id 2F9723858D35 for ; Sat, 21 Oct 2023 18:07:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2F9723858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2F9723858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::42f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697911648; cv=none; b=Uf5/k0tZlTNUAIO3jSRwzY+0o8EpAvZv5PmbRAgOlJ6AKyUvxbwJO6SpPVKKxezBmaBOaJxlqJ6UnwmKN/g3CFljbidVV7DdSsNMaSzinqt24WbR1wDTvxDFJ/o5mttE21a2L+7l1FkLjkay/gGE/D4rAj1fOTbz9YN8oQMEqzI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697911648; c=relaxed/simple; bh=nolTCphAPPjrP4pDxUcTei2L4H4ugIkjufg9O8UkSJM=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=t/6gf0m1YPkOgz7SziJY38EuR++lpc8pxXwnDIgPWlhFoETYPA2TMOhFd/dmbx4u8Pd0xvjpSCzZxrA0GlgXV/3AS+SG+rOb0PSGl+F+3HV0NrukkRpABu+T80nP2L5BfJeuFsNd5S86LBwzOVqJvX3lcF+iD0nZMw0yHMV9cwQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-6b87c1edfd5so1521475b3a.1 for ; Sat, 21 Oct 2023 11:07:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697911637; x=1698516437; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=UFnd02Bdqj46zap2k8mw8ICe37zHQYQm6n7mv8WidI4=; b=UcHo5UFf4whxShn1KmrjYsOovjndRIn5dM0a1I6g0+cAeelcZoT54d6WN/Jj4rb7Zo 1BDmQtXzmGcKNS9gLNEz0bygoiih8kCNvIGjFEuPmcdP/omD+Vmam4DZke6YG5dXsKfX 6kKYcZZyZWRpCOM1q9q8bFWAb/TinWwegehzLrJJFtM22RlWxYUCjoZFxWnkGtKFmysd T3U6H1/KIzQvcM7LPBN43BgSBefvBneXRM8mouf9RdZgIydHJm0iNIJg3JQIjQIP52G7 kRq3NsC4KIqZpOmjMU2jwnzjK1cpuq+5aDhb+hXyJXRx1Shc2lBptNZe/xxCX1yoMeS9 3vEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697911637; x=1698516437; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=UFnd02Bdqj46zap2k8mw8ICe37zHQYQm6n7mv8WidI4=; b=lBgEkkSeTM4DVY5z4ug/mzRL0eQPUcKg43n1mJREL6k/mPMmaFMISFJ+VNpZNNnNJc 8KSTgTCaDTGU7rxBYTxy2/Rnu5TULj5I7WivquwSFAKphVsfEVNR/5vnlfurd7zgH7wp bH8T3kE7T7+K/pCxoc5cwOGQC9d9FCAXrZ9lFd6ATUHi4RxVXMj60YEE8AH74UtpuL1C SmoXskX7OZX3L9/IewK2urOh1OL1eqV/Zmy7Fne1BjyU97lMPuiIbMATETelXnN04pwi p7oiPezDhx7xfn96WVS+ErAYozICWyL9y+UUXOczLNVa4ryMwlSLTVgoHpoDG6E/CrBR 51bQ== X-Gm-Message-State: AOJu0YzN9K8Xgk7RWq/Q12kB2yMzaqXk5BOVCLpygoxj1MqhHkCSJHrX 8yd8p/yXU+HtNmsjloEA1ZkXykHHJ+aB1A== X-Received: by 2002:a05:6a00:15c2:b0:693:3be8:feba with SMTP id o2-20020a056a0015c200b006933be8febamr4282954pfu.19.1697911636799; Sat, 21 Oct 2023 11:07:16 -0700 (PDT) Received: from xeond2.wrightpinski.org ([98.97.114.173]) by smtp.gmail.com with ESMTPSA id d7-20020aa797a7000000b0068fadc9226dsm3542501pfq.33.2023.10.21.11.07.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Oct 2023 11:07:16 -0700 (PDT) From: Andrew Pinski To: gcc-patches@gcc.gnu.org Cc: Andrew Pinski Subject: [PATCH] convert_to_complex vs invalid_conversion [PR111903] Date: Sat, 21 Oct 2023 11:07:12 -0700 Message-Id: <20231021180712.370694-1-pinskia@gmail.com> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, 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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780389428232029160 X-GMAIL-MSGID: 1780389428232029160 convert_to_complex when creating a COMPLEX_EXPR does not currently check if either the real or imag parts was not error_mark_node. This later on confuses the gimpilfier when there was a SAVE_EXPR wrapped around that COMPLEX_EXPR. The simple fix is after calling convert inside convert_to_complex_1, check that the either result was an error_operand and return an error_mark_node in that case. Bootstrapped and tested on x86_64-linux-gnu with no regressions. PR c/111903 gcc/ChangeLog: * convert.cc (convert_to_complex_1): Return error_mark_node if either convert was an error when converting from a scalar. gcc/testsuite/ChangeLog: * gcc.target/i386/float16-8.c: New test. --- gcc/convert.cc | 9 +++++++-- gcc/testsuite/gcc.target/i386/float16-8.c | 12 ++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/float16-8.c diff --git a/gcc/convert.cc b/gcc/convert.cc index 80d86fe3708..ac6af7026a7 100644 --- a/gcc/convert.cc +++ b/gcc/convert.cc @@ -1006,8 +1006,13 @@ convert_to_complex_1 (tree type, tree expr, bool fold_p) case ENUMERAL_TYPE: case BOOLEAN_TYPE: case BITINT_TYPE: - return build2 (COMPLEX_EXPR, type, convert (subtype, expr), - convert (subtype, integer_zero_node)); + { + tree real = convert (subtype, expr); + tree imag = convert (subtype, integer_zero_node); + if (error_operand_p (real) || error_operand_p (imag)) + return error_mark_node; + return build2 (COMPLEX_EXPR, type, real, imag); + } case COMPLEX_TYPE: { diff --git a/gcc/testsuite/gcc.target/i386/float16-8.c b/gcc/testsuite/gcc.target/i386/float16-8.c new file mode 100644 index 00000000000..003f82e7146 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/float16-8.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-mno-sse" } */ +/* PR c/111903 */ + +int i; +_Float16 f; +int bar(...); +void +foo (void) +{ + i /= bar ((_Complex _Float16) f); /* { dg-error "" } */ +}