From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by sourceware.org (Postfix) with ESMTPS id 6C4E43851C24 for ; Sun, 14 Mar 2021 05:55:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6C4E43851C24 Received: by mail-pl1-x630.google.com with SMTP id s7so13768607plg.5 for ; Sat, 13 Mar 2021 21:55:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:from:to:references:in-reply-to :subject:date:mime-version:content-transfer-encoding:importance; bh=69vqCYwUzGh2SqEpmNk5ssjRKLmVzyCsHlBwAsN4PkY=; b=EMKHFbFAm/bfLGCQ7/iyy5EE7tzrMBU0ol1LgqDwXHvOek5ZrZLylyCDD6zjQQWmou UHgEGVu/h2gYyslxcOrp1vMMG6AxS9bSykfX5WtTGlKEp7vUTueAQmZcJGT2e2ZuXLlq ogH1zDwjWu2MYjK48EzwJbUdmDqDxYNYl405qKoUgtemDGpABj2vHWm23Ud/z43QKEZQ yByr6DhAXzVui9BDIdRhbJvKxnNZxCGtGkkJkrCGz5aRchdUFEb/rn3wf6USwKawF3dr nwMREsiUWayuLvod0k2XMI46AEVPjDxwBEpKvrbqHYExVzWzywV+OLxlZuftsFJHNrRX PDOw== X-Gm-Message-State: AOAM533poV3ZoSOY8ThldkRjRb3LWgQmB+vWFvBahsNz/ZXdb5Dhmme+ 8SWKwMRkiiVDDayabk/pJohXY2EOqro= X-Google-Smtp-Source: ABdhPJwJwnrHUMV4nSP9Pr7iR07EtmoLTTeyxX7MRaVosR7wvAP1CuxrfS3FNmy9SxAVFsen07DvIg== X-Received: by 2002:a17:90b:1044:: with SMTP id gq4mr6595124pjb.232.1615701338104; Sat, 13 Mar 2021 21:55:38 -0800 (PST) Received: from DESKTOP0OKG1VA ([202.169.113.201]) by smtp.gmail.com with ESMTPSA id d22sm9228266pfn.25.2021.03.13.21.55.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 13 Mar 2021 21:55:37 -0800 (PST) Message-ID: From: "Paul Edwards" To: References: <200911241405.nAOE5Jsd022678@d12av02.megacenter.de.ibm.com> <7B52F224E6EE465EB95237D5A0D9A15F@Paullaptop> <84fc9c000911280802j3a0be6b1p1241d81d91f0672e@mail.gmail.com> In-Reply-To: <84fc9c000911280802j3a0be6b1p1241d81d91f0672e@mail.gmail.com> Subject: negative indexes Date: Sun, 14 Mar 2021 16:55:32 +1100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal Importance: Normal X-Mailer: Microsoft Windows Live Mail 16.4.3528.331 X-MimeOLE: Produced By Microsoft MimeOLE V16.4.3528.331 X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_20, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, STOX_REPLY_TYPE, STOX_REPLY_TYPE_WITHOUT_QUOTES, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Mar 2021 05:55:42 -0000 If I have code like this: char foo(char *p) { return (p[-1]); } It generates a negative index, like this: * Function foo code L 2,=F'-1' L 3,0(11) SLR 15,15 IC 15,0(2,3) * Function foo epilogue See that (2,3) - that is adding both R2 + R3. R3 is a pointer to a location in 4 GiB space. R2 is now 0xFFFFFFFF In 64-bit mode, both of those values are added together and there is no address wrap, so it accesses memory above the 4 GiB boundary (between 4 GiB and 8 GiB to be precise) which I don't have access to. Is there a way of constraining index registers to positive values? I want it to instead generate ALR 3,2 to add these two values together using 32-bit arithmetic, causing truncation at 32 bits, then it can do IC 15,0(3) (ie no index) I'm using GCC 3.2.3 using the i370 target if it makes a difference. Thanks. Paul.