From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by sourceware.org (Postfix) with ESMTPS id C3124385841F for ; Fri, 9 Feb 2024 21:38:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C3124385841F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C3124385841F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::102d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707514701; cv=none; b=IPdbOq9om/cpWrs1ydbHI5ZI3ouCxChkvV0dbbYCCQ5Yhlkv0FmbgszGL5lhL8ifSmuk8Kn4DVsvaOKpa2wbJ5CcNyZVGYgcA1h5vznpJ/Fd12vwRm3AUfiilqBrLGJx9sKQhd3ENDGAULEie8E7KyEdojn41vsgDL/CmJByJMQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707514701; c=relaxed/simple; bh=55ZuKHhWnyWgcXZ3LhHMOXShwG4XKOVMlIpGb2f3wlY=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=CtKddp45azYsbqvf8kARTLY429wRcvVr9ePQ9FO25RYKdkiqFwUOyfY7cJyvL4oPyQ3t8qZevmfum06mpA7spERqbpiikJjlqlbjYXKCouECvoZFXvt+T0rNXKl794YEzZPxfLOHdMdlJqA0rrvA9TZG3NA+X/ALiat6gHlHrzI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pj1-x102d.google.com with SMTP id 98e67ed59e1d1-290d59df3f0so1056748a91.2 for ; Fri, 09 Feb 2024 13:38:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707514698; x=1708119498; darn=gcc.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=naaLiDzFipf3lq3TZfIQIHIx+UWzsU/9NiK070Moj6Q=; b=eeCS/fp8yHgViYgJLAX6VO6xgE28VHug8wdzGOnUwfKWM1Te9CCLdszGnATfjd/HpB xYOHjvEOnfdFJEAf2pV2w7Tl7XX2jvQ1UdiF0g6SU9ad8IzttuQXIBZd4BtayuOD780C BKbWL8V8kQP6HVribPcBBMZPrQVknaSmIKaeYXtyjOzimYfxa26d8GzZfNS3kTbzgAR1 I/vr0mIHniuV/p/o2Wm1LId6LnEBnG63Yw6p4UJcsMt4sseO2hjWxCDCxJCTTEFTmyX/ QjWEGa796xo85w1YXw6jQAe8z3+IbpzHUH2RdCKQePIZ1FJcD/T7sTOEcZl4UpAFi+DM GNXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707514698; x=1708119498; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=naaLiDzFipf3lq3TZfIQIHIx+UWzsU/9NiK070Moj6Q=; b=kscdMaRH358xHuWYa4jYAO7tDCGmt80PTT2XrWUfLIzVZp9Hk3T2pycGmYfOONLyPR uZOsV08iMgaheV4bZm7R4/mkvDhPZwXU7YUhIjwExRp84c6KDMU/9nVd8e5UKX29GRPD 8cmGdXAJ6iloL6IBFue0/NbX+cemP6ULBX5avCBFWJVLaEnx/gMtNYhu+jCz/MDe9SZl RieCdvvlzfaxFaoQqVCRDLvMuFxXUCG6rpzzEZMu6Sjwp/bw4fBe5IoZVca+AP4zqbyz qph4paPDo9Df1WVj4zTWQEgRWtgDTycNszNH4UGR1Qwh6NQgyeuVfxFGTm4dcQrTkN+u tUlA== X-Gm-Message-State: AOJu0Yy7shWOJ+53SC+epYp/R6gj4TaS00pawcTmvXxMaLQZWiMDb6Es qLkjc6gE1Yzr6oOtiQYhLTZMCi92P0x066/2suHlDRKBbYG3cmo5dGufTlHeqo3HlzQxMDIhaqb +cRLIP1ceP+MeGT+fkX9cqa5TcCo= X-Google-Smtp-Source: AGHT+IHxfYTiojr/l8J2O9jr7Y/U7TK5gHoicKh0BP16wQuQztI1ZNRKnrUWHotOblQpE2ZIHtajplDo1OlQ4AS/eK4= X-Received: by 2002:a17:90b:1254:b0:296:3167:9616 with SMTP id gx20-20020a17090b125400b0029631679616mr308678pjb.22.1707514697552; Fri, 09 Feb 2024 13:38:17 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Paul Edwards Date: Sat, 10 Feb 2024 05:38:05 +0800 Message-ID: Subject: Re: gcc 3.2.3 x64 negative indexes To: Jakub Jelinek Cc: GCC Development Content-Type: multipart/alternative; boundary="000000000000ff17d00610f9bef3" X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE,LOTS_OF_MONEY,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --000000000000ff17d00610f9bef3 Content-Type: text/plain; charset="UTF-8" Oh - I switched to -2 to make debugging easier: D:\devel\gcc\gcc>type foo.c int foo(char *in) { return in[-2]; } D:\devel\gcc\gcc> Note that my flavor of gcc 3.2.3 can be found in gcc-stage*.zip in custom.zip at http://pdos.org On Sat, 10 Feb 2024 at 05:34, Paul Edwards wrote: > On Wed, 7 Feb 2024 at 23:12, Jakub Jelinek wrote: > On Wed, Feb 07, 2024 at 11:02:51PM +0800, Paul Edwards via Gcc wrote: > > >> I am using a slightly modified gcc 3.2.3 for x86_64 and for this code: > > > Don't, gcc 3.2.3 is not supported for more than 20 years already. > > And the i370 target hasn't been supported for that long > either - but that's a target I want too. > > And nor has any version ever run on MVS 3.8J - but > that's an execution platform I want too. > > And the same goes for PDOS/386 as an execution platform. > > >> int fff(char *x) > >> { > >> return (x[-1]); > >> } > > > >> It is generating: > > > >> .globl fff > >> fff: > >> .LFB2: > >> movl $4294967295, %eax > >> movsbl (%rax,%rcx),%eax > > > That said, I can't reproduce it and get > > movsbl -1(%rdi),%eax > > ret > > from 3.2.3. > > Thanks for that! So one of the "slight modifications" > was to switch to Win64 ABI, which is why rcx is being > selected instead of rdi. So that bit is expected. > > So I need to know why I'm not getting -1. > > Since your email I have been trying to explain that. > It is likely a problem with the C library I am using > (PDPCLIB) - strtol or something like that. > > I am using 64-bit longs and I can see that that large > value (-1 as unsigned 32-bit) is being stored in the > 64-bit field and being preserved. > > So far I have tracked it down to happening in the > early stages. fold() is called and I can see that it > is initially good for something, and bad later. > > I'm still working on it. > > BFN. Paul. > > > fold-const.c > > tree > fold (expr) > tree expr; > { > tree t = expr; > tree t1 = NULL_TREE; > tree tem; > tree type = TREE_TYPE (expr); > tree arg0 = NULL_TREE, arg1 = NULL_TREE; > enum tree_code code = TREE_CODE (t); > int kind = TREE_CODE_CLASS (code); > int invert; > /* WINS will be nonzero when the switch is done > if all operands are constant. */ > int wins = 1; > > printf("bbb in fold\n"); > /* Don't try to process an RTL_EXPR since its operands aren't trees. > Likewise for a SAVE_EXPR that's already been evaluated. */ > if (code == RTL_EXPR || (code == SAVE_EXPR && SAVE_EXPR_RTL (t) != 0)) > return t; > > /* Return right away if a constant. */ > if (kind == 'c') > return t; > > printf("bbb fold2\n"); > printf("bbb fold2b %d\n", (int)TREE_CODE(t)); > if (TREE_CODE (t) == INTEGER_CST) > { > printf("bbb fold2c is %ld\n", > (long)TREE_INT_CST_LOW (t)); > } > > > ... > > > /* If this is a commutative operation, and ARG0 is a constant, move it > to ARG1 to reduce the number of tests below. */ > if ((code == PLUS_EXPR || code == MULT_EXPR || code == MIN_EXPR > || code == MAX_EXPR || code == BIT_IOR_EXPR || code == BIT_XOR_EXPR > || code == BIT_AND_EXPR) > && (TREE_CODE (arg0) == INTEGER_CST || TREE_CODE (arg0) == REAL_CST)) > { > printf("bbb fold3\n"); > printf("bbb fold3b is %ld\n", > (long)TREE_INT_CST_LOW (arg0)); > > tem = arg0; arg0 = arg1; arg1 = tem; > > tem = TREE_OPERAND (t, 0); TREE_OPERAND (t, 0) = TREE_OPERAND (t, 1); > TREE_OPERAND (t, 1) = tem; > } > > printf("bbb fold4\n"); > > > > temp.txt: bbb fold2 > temp.txt: bbb fold2b 77 > temp.txt: bbb fold4 > temp.txt: bbb fold5 > temp.txt: bbb -2 -1 > temp.txt: bbbj 0 > temp.txt: bbbs1 > temp.txt: bbbs2 > temp.txt: bbbs9 > temp.txt: bbbq > temp.txt: bbb in fold > temp.txt: bbb fold2 > temp.txt: bbb fold2b 115 > temp.txt: bbb fold4 > temp.txt: bbb fold5 > temp.txt: bbb -2 -1 > temp.txt: bbbj 0 > temp.txt: bbb in fold > temp.txt: bbb fold2 > temp.txt: bbb fold2b 115 > temp.txt: bbb fold4 > temp.txt: bbb fold5 > temp.txt: bbb 1 0 > temp.txt: bbbj 0 > temp.txt: bbbq > temp.txt: bbb about to do build > temp.txt: bbbo > temp.txt: bbb done build > temp.txt: bbb in fold > temp.txt: bbb fold2 > temp.txt: bbb fold2b 61 > temp.txt: bbb fold3 > temp.txt: bbb fold3b is 4294967294 > temp.txt: bbb fold4 > temp.txt: bbb fold5 > temp.txt: bbb 4294967294 0 > > --000000000000ff17d00610f9bef3--