From patchwork Tue Jul 25 19:07:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 1812833 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=lm9BXrW2; dkim-atps=neutral Received: from server2.sourceware.org (ip-8-43-85-97.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 (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4R9RPn2XhNz1yYc for ; Wed, 26 Jul 2023 05:08:12 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 085FF385483E for ; Tue, 25 Jul 2023 19:08:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 085FF385483E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1690312090; bh=V52+O4m5/Yg1BJQ2j+k306boa4mNm/ZQadOP55Dtw4w=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=lm9BXrW2l29GUjq1ZVFngyc19KT4rjUbud5DHgvAHxNw1196HB7ybdhPJoP3xbSd0 iRhOD0tAyNcMj4cZxlti9eeN8L7u12aK3VL3aN5KW+x4Gv4JOa6gdJf+lef755E9+l 6SPkRokhdTY5coq07dRbcyS72Ly3xp/QSnCn6JRU= 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.133.124]) by sourceware.org (Postfix) with ESMTPS id D99D7385840F for ; Tue, 25 Jul 2023 19:07:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D99D7385840F Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-356-m2n4e6O1NKeSZwXR4cKG8w-1; Tue, 25 Jul 2023 15:07:47 -0400 X-MC-Unique: m2n4e6O1NKeSZwXR4cKG8w-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9D0CA29A9CA3 for ; Tue, 25 Jul 2023 19:07:47 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.192.9]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 242411454147; Tue, 25 Jul 2023 19:07:46 +0000 (UTC) Received: from abulafia.quesejoda.com (localhost [127.0.0.1]) by abulafia.quesejoda.com (8.17.1/8.17.1) with ESMTPS id 36PJ7jPM037803 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 25 Jul 2023 21:07:45 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 36PJ7jpq037802; Tue, 25 Jul 2023 21:07:45 +0200 To: GCC patches Cc: Andrew MacLeod , Aldy Hernandez Subject: [PATCH] Initialize value in bit_value_unop. Date: Tue, 25 Jul 2023 21:07:31 +0200 Message-ID: <20230725190739.37779-3-aldyh@redhat.com> In-Reply-To: <20230725190739.37779-1-aldyh@redhat.com> References: <20230725190739.37779-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Aldy Hernandez via Gcc-patches From: Aldy Hernandez Reply-To: Aldy Hernandez Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" bit_value_binop initializes VAL regardless of the final mask. It even has a comment to that effect: /* Ensure that VAL is initialized (to any value). */ However, bit_value_unop, which in theory shares the same API, does not. This causes range-ops to choke on uninitialized VALs for some inputs to ABS. Instead of fixing the callers, it's cleaner to make bit_value_unop and bit_value_binop consistent. OK for trunk? gcc/ChangeLog: * tree-ssa-ccp.cc (bit_value_unop): Initialize val when appropriate. --- gcc/tree-ssa-ccp.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gcc/tree-ssa-ccp.cc b/gcc/tree-ssa-ccp.cc index 73fb7c11c64..15e65f16008 100644 --- a/gcc/tree-ssa-ccp.cc +++ b/gcc/tree-ssa-ccp.cc @@ -1359,7 +1359,10 @@ bit_value_unop (enum tree_code code, signop type_sgn, int type_precision, case ABS_EXPR: case ABSU_EXPR: if (wi::sext (rmask, rtype_precision) == -1) - *mask = -1; + { + *mask = -1; + *val = 0; + } else if (wi::neg_p (rmask)) { /* Result is either rval or -rval. */ @@ -1385,6 +1388,7 @@ bit_value_unop (enum tree_code code, signop type_sgn, int type_precision, default: *mask = -1; + *val = 0; break; } }