From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by sourceware.org (Postfix) with ESMTPS id 098EC3857C6B for ; Sun, 14 Mar 2021 08:05:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 098EC3857C6B Received: by mail-ej1-x635.google.com with SMTP id p8so61130247ejb.10 for ; Sun, 14 Mar 2021 00:05:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:user-agent:in-reply-to:references :mime-version:content-transfer-encoding:subject:to:from:message-id; bh=PPmlcBzVYkUBdcDoOR2Hhz+SMOeRPnpIouniYTqjvT0=; b=o8WSSVwf7GNJo/AbVyG2N5P3bIrV/LwqaR6ZIHZA7+l1R4ENLmoKMVZvD7KXtT4JIO cWcSV4e7dN4n8QNu+5X/io/fI7t/4olWAK9ww67U1h8oi3TkxRNGL2M8ADia+UYaxHS6 U+m352sEbjS6TwkSbSuhFeMxYdypFR9jogtgjEoQ5nB417qtUhVRSabtyVR45iJCCPeK QsmcJ0G+HH8/RM0QflTdw8kTZkbGUGjlm9M+29zmzxOIzDCEU0c0Ow1paB+wWEJ71lvw 0BNrVnvV0O7hyU/uq648VV1hQ16SZeQAHTCFRWGQYqapSjD2GWOowor5K1NFuJ5CW7sz GgMQ== X-Gm-Message-State: AOAM532bt2NUneJCkDWvpHTCF6KCNXoAdLMmKqD+IjCS9jqYlOgD/wWE 3Ds/L5diinACAlpFvS5bAAg= X-Google-Smtp-Source: ABdhPJy/2GgwagGRbrUbXzOGFvM6jaqCbcpePfd0uj9a3uyAzoryq+g69y6aO+o3k/nHnI5o/TvYVQ== X-Received: by 2002:a17:906:f1c8:: with SMTP id gx8mr17866309ejb.385.1615709149071; Sun, 14 Mar 2021 00:05:49 -0800 (PST) Received: from [192.168.178.32] (dynamic-095-115-050-183.95.115.pool.telefonica.de. [95.115.50.183]) by smtp.gmail.com with ESMTPSA id hd8sm5093782ejc.92.2021.03.14.00.05.48 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Mar 2021 00:05:48 -0800 (PST) Date: Sun, 14 Mar 2021 09:05:46 +0100 User-Agent: K-9 Mail for Android In-Reply-To: References: <200911241405.nAOE5Jsd022678@d12av02.megacenter.de.ibm.com> <7B52F224E6EE465EB95237D5A0D9A15F@Paullaptop> <84fc9c000911280802j3a0be6b1p1241d81d91f0672e@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: negative indexes To: Paul Edwards , Paul Edwards via Gcc , gcc@gcc.gnu.org From: Richard Biener Message-ID: <7926CAF0-69E7-415D-B635-B7C004EC838A@gmail.com> X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham 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 08:05:52 -0000 On March 14, 2021 6:55:32 AM GMT+01:00, Paul Edwards via Gcc wrote: >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,=3DF'-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=2E >R3 is a pointer to a location in 4 GiB space=2E >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=2E > >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=2E2=2E3 using the i370 target if it makes a difference=2E You are likely missing a fix that sign extends offsets on Pmode!=3Dptr_mod= e targets=2E 3=2E2=2E3 is really old now ;)=20 Richard=2E=20 >Thanks=2E Paul=2E