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.129.124]) by sourceware.org (Postfix) with ESMTPS id AEB543858C00 for ; Tue, 23 May 2023 13:01:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AEB543858C00 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=1684846868; 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=Q3XewnvdtdvPs1VpEkxbveNoZPNwxqIE1PQj/mbzDbc=; b=BpBW/M5uGxN3T9bqaOpGPfFNWsrZkPjFtGlG9YOuMMqcVKVbxHcz9RaWVsMxMLJy2MQywn X53fnwNPP9G171g368a8Y6Lk0rOM0LlEFbNLE+VoxFByJjMKW1kSxn4qo4pmGVCbYmEg+G h2tLf1P1JwAg6+aJwyV87d4ugwznNDI= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-615-5S6mZz3-PyC9v7hbApXEiw-1; Tue, 23 May 2023 09:01:07 -0400 X-MC-Unique: 5S6mZz3-PyC9v7hbApXEiw-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-94a348facbbso940759866b.1 for ; Tue, 23 May 2023 06:01:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684846866; x=1687438866; h=content-transfer-encoding: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=Q3XewnvdtdvPs1VpEkxbveNoZPNwxqIE1PQj/mbzDbc=; b=N4bMFiZnynXo00cYDIpKcRua0add3dLkbnpuOGd9wmvkbZmnkxCqfQ4TXPgd9ZVAEH dPuYtDGAigjhYF08/rqdNsnL0E5RCfj6StP8W9tyoFUSP8eZumwYwrIxSXv4qjCMYVQM YM21JRZ5hbLMzGBTvuKFO4ZY4+rSGR4+fUgLk8AxcKeYbTB0BfZ0/bdc6zrK5AS6a0q0 Qqakegeur8XIRiA9o5XoBmRGHck1ZjLyA9gbI1xXXXs2KCMdlQFpWAaxW97JCS+EpG2s s3rXqPN+h7+Ia9eOuvq9XXsKsJBMv5AG0ZF9BIGAKoVth4lq8CQqQd3wfQlZrVSfEXj6 gDmQ== X-Gm-Message-State: AC+VfDy+Qjh+TdwOsVWOEcuLnvQ2vjo3S7RaAwuqADcfbfhc8bQNZ2Ji jGLzk1ZWdOm4H5ODmY9orPgzD0Cw4yH6mVEpZuSp4u6CFGeIAxf0HD42BUwBuXOHDYpTEbg+Vh7 6xEvYteIroa3w+exZRINcmbm62fMYO0KcPR7RDXtcgQ== X-Received: by 2002:a17:906:ef0e:b0:96a:1260:dbf5 with SMTP id f14-20020a170906ef0e00b0096a1260dbf5mr12950535ejs.45.1684846865932; Tue, 23 May 2023 06:01:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4wrPmswW/w7607/Yba4RGB+X2IfmzKTPo53cdbzsrPEqgBXLfY6zsVvBorwQTZ+v9M0rqLLHj5Voebe4G7fYg= X-Received: by 2002:a17:906:ef0e:b0:96a:1260:dbf5 with SMTP id f14-20020a170906ef0e00b0096a1260dbf5mr12950514ejs.45.1684846865588; Tue, 23 May 2023 06:01:05 -0700 (PDT) MIME-Version: 1.0 References: <20230523125836.642394-1-aldyh@redhat.com> In-Reply-To: <20230523125836.642394-1-aldyh@redhat.com> From: Aldy Hernandez Date: Tue, 23 May 2023 15:00:54 +0200 Message-ID: Subject: Re: [COMMITTED] Remove buggy special case in irange::invert [PR109934]. To: GCC patches Cc: Andrew MacLeod X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-11.3 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_H2,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: BTW, we should probably backport this to god knows how many branches. Aldy On Tue, May 23, 2023 at 2:58=E2=80=AFPM Aldy Hernandez w= rote: > > [Andrew, do you remotely remember what if anything this did? It came > from a wholesale merge from our long forgotten branch, so there's no > history on the specifics of it. Not important, I'm just curious. It > was probably me high on something.] > > This patch removes a buggy special case in irange::invert which seems > to have been broken for a while, and probably never triggered because > the legacy code was handled elsewhere, and the non-legacy code was > using an int_range_max of int_range<255> which made it extremely > likely for num_ranges =3D=3D 255. However, with auto-resizing ranges, > int_range_max will start off at 3 and can hit this bogus code in the > unswitching code. > > PR tree-optimization/109934 > > gcc/ChangeLog: > > * value-range.cc (irange::invert): Remove buggy special case. > > gcc/testsuite/ChangeLog: > > * gcc.dg/tree-ssa/pr109934.c: New test. > --- > gcc/testsuite/gcc.dg/tree-ssa/pr109934.c | 22 ++++++++++++++++++++++ > gcc/value-range.cc | 8 -------- > 2 files changed, 22 insertions(+), 8 deletions(-) > create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr109934.c > > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr109934.c b/gcc/testsuite/gcc= .dg/tree-ssa/pr109934.c > new file mode 100644 > index 00000000000..08bd5ce95c6 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr109934.c > @@ -0,0 +1,22 @@ > +// { dg-do run } > +// { dg-options "-O3" } > + > +int printf(const char *, ...); > +short a; > +long b =3D 3, c; > +int d(int e) { > + switch (e) > + case 111: > + case 222: > + case 44: > + return 0; > + return e; > +} > +int main() { > + for (; a >=3D 0; --a) > + if (d(c + 23) - 23) > + b =3D 0; > + > + if (b !=3D 3) > + __builtin_abort (); > +} > diff --git a/gcc/value-range.cc b/gcc/value-range.cc > index 45b1e655967..874a1843ebf 100644 > --- a/gcc/value-range.cc > +++ b/gcc/value-range.cc > @@ -1650,14 +1650,6 @@ irange::invert () > wide_int type_min =3D wi::min_value (prec, sign); > wide_int type_max =3D wi::max_value (prec, sign); > m_nonzero_mask =3D wi::minus_one (prec); > - if (m_num_ranges =3D=3D m_max_ranges > - && lower_bound () !=3D type_min > - && upper_bound () !=3D type_max) > - { > - m_base[1] =3D type_max; > - m_num_ranges =3D 1; > - return; > - } > > // At this point, we need one extra sub-range to represent the > // inverse. > -- > 2.40.1 >