From patchwork Thu Sep 22 18:58:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 57926 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 66278385801C for ; Thu, 22 Sep 2022 18:58:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 66278385801C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663873118; bh=6JMa1pAoEkayK/taNSC9m72iDiyFxEx8NRpa5VE+wFg=; h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=WIOU9ARh6BKvRueMlibXyye8FsAEWEcJvSPv5swrHKoH1WpsAmuehCjjR9Wpivh0P 16ZeZoSrq5cs1qfE8yEeQUDgEC9Oo3fRReGS4pux8cwI5pH2tzxzb/gDBTJedU26R0 U7Ew5rOLixylEWa2P6P6lUaCcnZxG2Mafso61wIM= 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.129.124]) by sourceware.org (Postfix) with ESMTPS id 6A0353858D38 for ; Thu, 22 Sep 2022 18:58:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6A0353858D38 Received: from mail-il1-f197.google.com (mail-il1-f197.google.com [209.85.166.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-501-dsb31I5GN9yUFF_ij0RMew-1; Thu, 22 Sep 2022 14:58:07 -0400 X-MC-Unique: dsb31I5GN9yUFF_ij0RMew-1 Received: by mail-il1-f197.google.com with SMTP id x14-20020a056e021cae00b002f1d5aca8c6so6187026ill.5 for ; Thu, 22 Sep 2022 11:58:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:references:cc:to:from:content-language:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date; bh=VSbtD4CdDgKEejVvpmC1byUdAG2SgCCLHf8d73tloKY=; b=u3rD5btt4j6lKEPTWseLka7Nqi7KmPA/a4Pb3JBotzwtzXZ5mfv9tL2gS6dm/7Xwo0 OoNdQ2WkGvpZ3VVWyIHQ8TdLmmsPf2neMl6jnbRYKt55lr13Reu8NZOhh5ngrM/R3Gyl hWBWVY+8FyoU1P0ugev3x2h1K20YYh6lK3AtvXuEQfM3N/v8XE5d6aIplcNfCDRQcrCA eVjhqo6kM7GUIVwBOeYl+54PqHkI4CJMWqIfKQg+/j74nThhmEnyoTXZLrwMexKXGzLZ 5EuY65N1BRmxEay6/LbXFK5EKjNXZu0/xb6Zy8mwV/alOK7rWTpGixc+1CcL8n96KxRp 4CoA== X-Gm-Message-State: ACrzQf0xjRg6AW9yNe1+D1YQhz/BPQYj9inyudAFykbGio5CP40BM9oc L5yRkIt8HEtzJMTzZ8/NixUJ8iX32RQ9jd/psFy65e5qeXW7oEsTPt1IvbYlbRNZKR+kgEZ2cAP bRpsY3F1vZXv338YqLlRrbEnnY8Zhj7Y4t5KZoo5p8ist08s7Sj/uvk4Y9BVPggC48BCuaA== X-Received: by 2002:a02:5108:0:b0:35a:eca0:92c1 with SMTP id s8-20020a025108000000b0035aeca092c1mr2844287jaa.81.1663873086656; Thu, 22 Sep 2022 11:58:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6FfyPl6eMpFAgDhdmdMrD/xScXWreYIhT8YmhP3uC6ZdszCJk4+a40Ks9/tYwSjdX8iYJ6lw== X-Received: by 2002:a02:5108:0:b0:35a:eca0:92c1 with SMTP id s8-20020a025108000000b0035aeca092c1mr2844275jaa.81.1663873086436; Thu, 22 Sep 2022 11:58:06 -0700 (PDT) Received: from ?IPV6:2607:fea8:a263:f600::3dbe? ([2607:fea8:a263:f600::3dbe]) by smtp.gmail.com with ESMTPSA id i11-20020a023b4b000000b00358437173c3sm2501709jaf.53.2022.09.22.11.58.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 22 Sep 2022 11:58:05 -0700 (PDT) Message-ID: Date: Thu, 22 Sep 2022 14:58:04 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.1 Subject: [PATCH 04/17] Fix calc_op1 for undefined op2_range. To: gcc-patches References: <571782f9-72e6-5c30-da55-b8d62d3a153e@redhat.com> In-Reply-To: <571782f9-72e6-5c30-da55-b8d62d3a153e@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.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, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Unary operations pass the type of operand 1 into op1_range.  If that range is undefined, the routine blindly picks the type of operand 2,which in the case of a unary op, does not exist and traps. Bootstrapped on x86_64-pc-linux-gnu with no regressions.  Pushed. Andrew From a7a6649f4e7c459a95dee1600554ad06aaeb1cf6 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Thu, 22 Sep 2022 10:27:17 -0400 Subject: [PATCH 04/17] Fix calc_op1 for undefined op2_range. Unary operations pass the type of operand 1 into op1_range. If that range is undefined, the routine blindly picks the type of operand 2, which in the case of a unary op, does not exist and traps. * gimple-range-op.cc (gimple_range_op_handler::calc_op1): Use operand 1 for second range if there is no operand 2. --- gcc/gimple-range-op.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gcc/gimple-range-op.cc b/gcc/gimple-range-op.cc index f03125a0fc5..ab5b389449d 100644 --- a/gcc/gimple-range-op.cc +++ b/gcc/gimple-range-op.cc @@ -208,10 +208,14 @@ gimple_range_op_handler::calc_op1 (vrange &r, const vrange &lhs_range, // If op2 is undefined, solve as if it is varying. if (op2_range.undefined_p ()) { - // This is sometimes invoked on single operand stmts. if (gimple_num_ops (m_stmt) < 3) return false; - tree op2_type = TREE_TYPE (operand2 ()); + tree op2_type; + // This is sometimes invoked on single operand stmts. + if (operand2 ()) + op2_type = TREE_TYPE (operand2 ()); + else + op2_type = TREE_TYPE (operand1 ()); Value_Range trange (op2_type); trange.set_varying (op2_type); return op1_range (r, type, lhs_range, trange); -- 2.37.3