From patchwork Thu Jul 22 12:54:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1508707 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=ZbFi2wt3; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GVstK1w0Vz9sjD for ; Thu, 22 Jul 2021 22:57:29 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D31973864811 for ; Thu, 22 Jul 2021 12:57:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D31973864811 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1626958646; bh=U7GjEJQQ+N/cnQm6Xx8CpX/3cGuDvK3tKzgo81HfLAQ=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ZbFi2wt3pSvTOUrdVuhNcC/3NL5dQw/avzau4s5CmopQDfBsEai0AnO5NxsR6Xfxv y89XvOMx89yabHYM2Oni/33pYbTeiVEaVX4G5rcjmq7hogxXYvQqVUarX46qAJiW0e rAX2TtI4QVm2xsRLwQPkGHk7ahxSCfGAf6mzmDqI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id EA6313844044 for ; Thu, 22 Jul 2021 12:54:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EA6313844044 Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-468-QZverFJDONGLdENQGdoA2w-1; Thu, 22 Jul 2021 08:54:12 -0400 X-MC-Unique: QZverFJDONGLdENQGdoA2w-1 Received: by mail-qt1-f198.google.com with SMTP id b6-20020a05622a0206b029025eb726dd9bso3350568qtx.8 for ; Thu, 22 Jul 2021 05:54:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version:content-language; bh=U7GjEJQQ+N/cnQm6Xx8CpX/3cGuDvK3tKzgo81HfLAQ=; b=JDLbzJbvC4LtC0pP2lyVfxKj1AmieLyRV3AClDKAYQ37A0ACEVW5tkXylLYVqRv4IG 4f2esuUsaoImHFBTq2aLJbYzkdFt2jD99dVtjndViDhQ1/jlcbhbpS3ZyaaVkPA6SEyk gonxVqD3djzVtfcUFijuO/iqmjPpvCPDeYLStHYlZeZFCojkUoA+iL+MvcE7PEoRmKDn m8MPdIoEWL5T3uRHJnDTRvjyvFbOR+6NDu11jnUlkVSvvBqI77dUFyY2N53GEGxjK4D8 gFwST2i0f8vEJMfFM8fzaI8SJD36L4vXIQ7z0SSpZQri+56108pQvWDIx/llNFQ1ZnRF UM1A== X-Gm-Message-State: AOAM533gvClgwkB4DIm/WaFLpSZKvBiq8ePuk3tm0QA9wNfbwNsOaeId ZR8oDWMU+0O1pKURqLKndrS9RIKzHl9hSy+NH/f8ffOhmbZ/xDTfhgG4/GQEjjNTDUxW7B3dBFA R9ncqr9YlllVqnSqBZg== X-Received: by 2002:a05:620a:a8f:: with SMTP id v15mr39740084qkg.257.1626958451609; Thu, 22 Jul 2021 05:54:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxo/FIc+WqdT760J0mDVj1NVeKvAOj4vArlhmGkVsrLSDivzt+9MtG2Yd/Gtwt/8MFZ4bfY2A== X-Received: by 2002:a05:620a:a8f:: with SMTP id v15mr39740070qkg.257.1626958451482; Thu, 22 Jul 2021 05:54:11 -0700 (PDT) Received: from ?IPv6:2607:fea8:a241:4600::74d4? ([2607:fea8:a241:4600::74d4]) by smtp.gmail.com with ESMTPSA id w185sm12946960qkd.30.2021.07.22.05.54.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 22 Jul 2021 05:54:10 -0700 (PDT) To: gcc-patches Subject: [COMMITTED] PR tree-optimization/101497 - Check for undefined on COND_EXPR before querying type. Message-ID: Date: Thu, 22 Jul 2021 08:54:09 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-CA X-Spam-Status: No, score=-13.5 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_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andrew MacLeod via Gcc-patches From: Andrew MacLeod Reply-To: Andrew MacLeod Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Can't ask for the type of an UNDEFINED value. Bootstrapped on x86_64 & powerpc64-unknown-linux-gnu with no regressions.  Pushed. Andrew From ea789238b2c24eedf70b56257235adf3d33c5a0a Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Mon, 19 Jul 2021 15:16:25 -0400 Subject: [PATCH 2/3] Check for undefined on COND_EXPR before querying type. gcc/ PR tree-optimization/101497 * gimple-range-fold.cc (fold_using_range::range_of_cond_expr): Check for undefined. gcc/testsuite * gcc.dg/pr101497.c: New. --- gcc/gimple-range-fold.cc | 3 ++- gcc/testsuite/gcc.dg/pr101497.c | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/pr101497.c diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc index f8578c013bc..f95af3d5866 100644 --- a/gcc/gimple-range-fold.cc +++ b/gcc/gimple-range-fold.cc @@ -1111,7 +1111,8 @@ fold_using_range::range_of_cond_expr (irange &r, gassign *s, fur_source &src) r = range1; r.union_ (range2); } - gcc_checking_assert (range_compatible_p (r.type (), type)); + gcc_checking_assert (r.undefined_p () + || range_compatible_p (r.type (), type)); return true; } diff --git a/gcc/testsuite/gcc.dg/pr101497.c b/gcc/testsuite/gcc.dg/pr101497.c new file mode 100644 index 00000000000..fcfe0594f9b --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr101497.c @@ -0,0 +1,13 @@ +/* PR tree-optimization/101497 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wno-div-by-zero" } */ + +char uc_1; +int i_4, func_12_uli_6; +void func_12() { + int *ptr_8 = &func_12_uli_6; + *ptr_8 = 0 >= 211 - uc_1 <= 0; + i_4 %= 0; + i_4 *= *ptr_8; +} + -- 2.17.2