From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by sourceware.org (Postfix) with ESMTPS id 6332A385B513 for ; Mon, 25 Sep 2023 10:52:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6332A385B513 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4053c6f0db8so51239215e9.3 for ; Mon, 25 Sep 2023 03:52:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1695639135; x=1696243935; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4F10ZycF+zS9SBq5BRtoJC4/cmgEp1IwDY5DA7k26sE=; b=ADd7CuCBGYVokD23GqmwS6xrhraHgQrK+XTPpdOE9hAxD8flO934UcJt4K6AujxE/s oM8PODNjnPLdSGeUpSxESbD9A7VZbVJxCYMGa/PmMOMLRgmE2ifjxeJOXUYLKj1TTzIQ RNAqvn3dnpb/tvmiKrQq7Bw6+qX23tuRqb/ReO7s9E3tJWiCPP2Is5Lvxr9ye1v95o66 9Gar1Vrd2D6yaIo1Ig7hPwBzlEhC/Ese5D5uoF0S+VVTsezq27qYqi4n59BrafqiTILh u6hzjvkTeCwhsHDSSmIpfyhwuBVQKCzxR4hKfgHi7OwB9koxLx2V8kvHf2FYWdCDNvzD um6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695639135; x=1696243935; 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=4F10ZycF+zS9SBq5BRtoJC4/cmgEp1IwDY5DA7k26sE=; b=SjbRd5o1PeEregUzBpyFZWpndQ+c5fzdd3WoiFH4OckkFqSAsYRu8wn4tjsWpr1u72 CnglRnObyDelOYkV9RbKIj6YFymkbjM98mgQNFupo8RlmxKTbNlR5+g7IEzr1kZ90Ol/ ZxqVI6STkEVRIr+bdixQ0fNttKP2YrbH7RRFYuwsFh8VEwFhaTj0rkwb77quc3/R66kn BFrV2FEqd7uA/04ixjUtc19gA922hgvbMUtqpOK+8kuJ+7DZywyc0D4tRV4eEruVPjfX uf4Rc1Tk/VO+6Sz61CmfZamCqYTPz1xPt76qdqnBW3tEhfVsaurq7vI+LR9QSewgTJxT nW6g== X-Gm-Message-State: AOJu0YyXu5AgCvj2oaANLGl5lSQgkTU5DSILqQKV+y3dYHQ3kK+mj1Mt uGRnHftxqcjxyd4XzyzDgOQdTmmWjAwB2o+YgSGgkg== X-Google-Smtp-Source: AGHT+IEgqSTNFLtpmCXJWR035fa7H/cPmIpaQPkgObobNYFIR74WCI37xNPcmtvihtpHOeTekBMZJg== X-Received: by 2002:a7b:c38a:0:b0:405:514d:eb09 with SMTP id s10-20020a7bc38a000000b00405514deb09mr5982414wmj.25.1695639135069; Mon, 25 Sep 2023 03:52:15 -0700 (PDT) Received: from fomalhaut.localnet ([2a01:e0a:8d5:d990:e654:e8ff:fe8f:2ce6]) by smtp.gmail.com with ESMTPSA id x6-20020a5d60c6000000b0031f300a4c26sm11484674wrt.93.2023.09.25.03.52.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 03:52:14 -0700 (PDT) From: Eric Botcazou X-Google-Original-From: Eric Botcazou To: Stefan Schulze Frielinghaus Cc: gcc-patches@gcc.gnu.org Subject: Re: PING^5: [PATCH] rtl-optimization/110939 Really fix narrow comparison of memory and constant Date: Mon, 25 Sep 2023 12:52:14 +0200 Message-ID: <10342490.nUPlyArG6x@fomalhaut> In-Reply-To: References: <20230810130402.752335-2-stefansf@linux.ibm.com> <1a4f7fdbde6ff8f4a36426701bc5d68bc855d7e8.camel@xry111.site> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 List-Id: > This is why I got a bit uncertain and hoped to get some feedback whether > my intuition is correct or not. Meanwhile I also found a comment in > the internals book at "14.7 Constant Expression Types" where we have: > > "Constants generated for modes with fewer bits than in HOST_WIDE_INT > must be sign extended to full width (e.g., with gen_int_mode). > [...] > Note however that values are neither inherently signed nor > inherently unsigned; where necessary, signedness is determined by > the rtl operation instead." > > At least this and the assert statement document that the normal form of > a CONST_INT is kind of special w.r.t. unsigned integers. Is there > anyone who can shed some light on _why_ such a normal form was chosen? In RTL integral values have no sign, they just represent a given pattern of bits so, in order to have a 1-to-1 mapping, you need to choose a canonical form. The signed form is probably more natural and, since CONST_INTs have no mode, the same objects are used for e.g. QImode and HImode, which means that you need to sign-extend the bit pattern. -- Eric Botcazou