From patchwork Thu Jul 11 12:12:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: YunQiang Su X-Patchwork-Id: 1959293 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=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=aqLr5Hvr; 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 4WKYXN3pDtz1xqj for ; Thu, 11 Jul 2024 22:13:08 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BB84F3870C26 for ; Thu, 11 Jul 2024 12:13:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BB84F3870C26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1720699986; bh=OrD3Wpd5BKlAriXEUSal0wESn3DIqvf1knfE+nhhpqA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=aqLr5HvrrIxL04WHhSLD28TzTooWbdAfohT5OF5MPg2ifpa0GoipPMPOp02gAxNmM 7dMcfa3UjTB/3C/gu/06GH1062guWjyQ6IZDVYn7v0WxLk9zwsjO6CKNXtVEuF3UuP BLgsCyK5iGFlCROYbsROm7GWaN3sbPrcGTDOt25s= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) by sourceware.org (Postfix) with ESMTPS id E3A2D38432FD for ; Thu, 11 Jul 2024 12:12:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E3A2D38432FD Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E3A2D38432FD Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.215.170 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720699955; cv=none; b=NdGzcaZ7oHblpuUQyHBIqgfv9poSLnHCPz8CwCMXRviIwE2j6pH2/OwW/0OcUu2iRQ8d1ZIafENmwbG3lPFHmCevLEbQrLBFRv+kGSbEq2dwrZT3Ooq7MyF6ZJ/6SPNf1HgWs1W87vXnIBPnL/9r+hKUt6Xz5S9VpKaGpxKC7e8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720699955; c=relaxed/simple; bh=Z09s1LIkC7QvGQ1Y4egt791aMVS7utw2vZcIdKUV9mU=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=LmIM3ElktN3jUrS2XcX+eL2yMkp1vygCCqVhHCgdVEg2A9I/u/BUOwGXOjNWFrZGVzKYMd5NdlyS5cvojsbM1rYmZ+1j/7rVvshykXgDCQOAJnOQPzldpjytM3dVuqr7jlIucWzAhI8QL4gc/xU77h7+YaNYBN8ojgAJHKVhLv8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-f170.google.com with SMTP id 41be03b00d2f7-71871d5e087so524345a12.1 for ; Thu, 11 Jul 2024 05:12:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720699950; x=1721304750; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OrD3Wpd5BKlAriXEUSal0wESn3DIqvf1knfE+nhhpqA=; b=uXKheHiOWtEBQBROHtSJxNB0OUpGwLJuYXNvAmW2QcWnlIgVbYzpkRg0j/i4HCSZX2 Q64uSK5IlmC1byqgypeTlRHEP0rXXipoc+JFRlkNmMQnWcRGqIcdbtC6paqp/boTQrfr RlZK0fW2luCbIPtRZK+8tDyw84tvQ6tbThkeM6DYedsbeRJ+TloD+I2Fmod//9taFwxc K5zv8tL1gdfUSQLA+Hb5quJr6kAp2mwzvtelsNcqY5DTv5AMxGCpWd2/2xnlRKkXNUT+ gmEShaBYI2xQBUtvug8pChRs3lMdBoZaku2rgGgGFqpKb7WBM5Qfcx4p2Dk121tWRpyE s3+Q== X-Gm-Message-State: AOJu0YySnGdQlBzuEgGKfKhWW+pURibb5bV8r89khW4lOGOxFMfDPNmt Rdgz+l5IZ+NiZnma3Ogme168V4nbPQ+sEweAstZMEPSAgmTqHkwvskHvTmqC X-Google-Smtp-Source: AGHT+IG9tmDFjdEUe8qWyEU5qxOc+BjutRIT+DpjeUBdDa8lJzNEwh91rLZO2MoNu5mMhVXwCD5zPQ== X-Received: by 2002:a05:6a20:3948:b0:1c0:e4d6:9bec with SMTP id adf61e73a8af0-1c29820b7d0mr9763322637.7.1720699949634; Thu, 11 Jul 2024 05:12:29 -0700 (PDT) Received: from localhost.localdomain ([194.169.55.179]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fbb6abfc56sm49010545ad.196.2024.07.11.05.12.28 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 11 Jul 2024 05:12:29 -0700 (PDT) From: YunQiang Su To: gcc-patches@gcc.gnu.org Cc: YunQiang Su Subject: [PATCH 2/2] RISC-V: Allow uninitialized preferred_else_value for RVV Date: Thu, 11 Jul 2024 20:12:08 +0800 Message-Id: <20240711121208.45328-2-syq@gcc.gnu.org> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20240711121208.45328-1-syq@gcc.gnu.org> References: <20240711121208.45328-1-syq@gcc.gnu.org> MIME-Version: 1.0 X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK 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 From: YunQiang Su PR target/115840. In riscv_preferred_else_value, we create an uninitialized tmp var for else value, instead of the 0 (as default_preferred_else_value) or the pre-exists VAR (as aarch64 does), so that we can use agnostic policy. The problem is that `warn_uninit` will emit a warning: ({anonymous})’ may be used uninitialized Let's mark this tmp var as "allow_uninitialized". This problem is found when I try to build glibc with V extension. gcc PR target/115840. * config/riscv/riscv.cc(riscv_preferred_else_value): Mark tmp_var as allow_unitialized. gcc/testsuite * gcc.dg/vect/pr115840.c: New testcase. --- gcc/config/riscv/riscv.cc | 6 +++++- gcc/testsuite/gcc.dg/vect/pr115840.c | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/vect/pr115840.c diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index 61fa74e9322..08159d7cbbc 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -11431,7 +11431,11 @@ riscv_preferred_else_value (unsigned ifn, tree vectype, unsigned int nops, tree *ops) { if (riscv_v_ext_mode_p (TYPE_MODE (vectype))) - return get_or_create_ssa_default_def (cfun, create_tmp_var (vectype)); + { + tree tmp_var = create_tmp_var (vectype); + TREE_ALLOW_UNINITIALIZED (tmp_var) = 1; + return get_or_create_ssa_default_def (cfun, tmp_var); + } return default_preferred_else_value (ifn, vectype, nops, ops); } diff --git a/gcc/testsuite/gcc.dg/vect/pr115840.c b/gcc/testsuite/gcc.dg/vect/pr115840.c new file mode 100644 index 00000000000..09dc9e4eb7c --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr115840.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Wall -Werror" } */ + +double loads[16]; + +void +foo (double loadavg[], int count) +{ + for (int i = 0; i < count; i++) + loadavg[i] = loads[i] / 1.5; +}