From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690312069; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=V52+O4m5/Yg1BJQ2j+k306boa4mNm/ZQadOP55Dtw4w=; b=XLId+iD+BverqVveW4GN++gfk3Ma4DL5pgiH/w6UeQpgkTg36Hi/GF8qMO2K8xD5DmL4gR sQNP39ds4bOGPor1yCiDRtS/mbdmo7iJWq9AgSqbW1lTCCpPxhUP1nc0gPChf4FjksdF/r HIpBC0gwaROdjXj6Z1Yib7y2cccKYHc= 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 From: Aldy Hernandez 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 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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 List-Id: 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; } } -- 2.41.0