From patchwork Fri Nov 13 00:30:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1399466 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=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gcc.gnu.org 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=Nd8KLFEu; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (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 4CXKB72VVZz9sTR for ; Fri, 13 Nov 2020 11:30:21 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A29E43861035; Fri, 13 Nov 2020 00:30:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A29E43861035 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1605227419; bh=voHfMSzsigtouWK8e89ndl3TMwKVWL6bun4djDXQXj0=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Nd8KLFEu/cM7+6NdRzwMBXAl/lobc+e0ze3mV03nL5fVpvEXI5y27W2C+X+soERs2 rFcou9Uwn4NPeLe3geTphtU2VhoaMkVsFmZLBGHKw9aWbyhI3OfkhCeHkeSWYaHaxk VYD35GcFJqoi8PPkEA7qku7I4Lly4qt9hJFdOHo0= 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 [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id BE2033858024 for ; Fri, 13 Nov 2020 00:30:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BE2033858024 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-356-glrJzR1WPn6dZpuhgn9QLA-1; Thu, 12 Nov 2020 19:30:14 -0500 X-MC-Unique: glrJzR1WPn6dZpuhgn9QLA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 23A4D107464A; Fri, 13 Nov 2020 00:30:13 +0000 (UTC) Received: from [10.10.119.201] (ovpn-119-201.rdu2.redhat.com [10.10.119.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id A10D05B4C9; Fri, 13 Nov 2020 00:30:09 +0000 (UTC) Subject: [PATCH] Change range_handler, was Re: Fix gimple_expr_code? To: Richard Biener , Andrew MacLeod via Gcc-patches References: <7dc11892-b595-68b2-7b28-5b16eec63941@redhat.com> <5975d49f-6ad3-df1e-838f-b7a7443a5dbb@redhat.com> Message-ID: <8a87a017-c03e-3628-8960-fee6d970f791@redhat.com> Date: Thu, 12 Nov 2020 19:30:08 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <5975d49f-6ad3-df1e-838f-b7a7443a5dbb@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.8 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_H5, RCVD_IN_MSPIKE_WL, 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-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@gcc.gnu.org Sender: "Gcc-patches" On 11/12/20 4:12 PM, Andrew MacLeod via Gcc-patches wrote: > On 11/12/20 3:53 PM, Richard Biener wrote: ... 😬 >> >>> But it means that gimple_expr_code() isn't returning the correct result >>> >>> for GIMPLE_SINGLE_RHS.... >> It depends. A SSA name isn't an expression code either. As said, the >> generic gimple_expr_code should be used with extreme care. > > what is an expression code?  It seems like its just a  tree_code > representing what is on the RHS?    Im not sure I understand why one > needs to be careful with it.  It only applies to COND, ASSIGN and > CALL. and its current right for everything except GIMPLE_SINGLE_RHS? > > If we dont fix gimple_expr_code, then Im basically going to be > reimplementing it myself... which seems kind of pointless. > > Andrew > > However, that said, It seems like reworking the accessor is probably better anyway.  Point taken on expr_type..  for a GIMPLE_COND I wasn't actually getting the type I really wanted as it turned out. anyway, fixed thusly. Bootstrapped on x86_64-pc-linux-gnu, no regressions.  pushed. Andrew commit ee24da1b983a89b05303f2ac8828dd8cbe28d3b4 Author: Andrew MacLeod Date: Thu Nov 12 19:25:59 2020 -0500 Change range_handler, was Re: Fix gimple_expr_code? Adjust the range_handler to not use gimple_expr_code/type. * gimple-range.h (gimple_range_handler): Use gimple_assign and gimple_cond routines to get type and code. * range-op.cc (range_op_handler): Check for integral types. diff --git a/gcc/gimple-range.h b/gcc/gimple-range.h index 0aa6d4672ee..88d2ada324b 100644 --- a/gcc/gimple-range.h +++ b/gcc/gimple-range.h @@ -97,8 +97,12 @@ extern bool gimple_range_calc_op2 (irange &r, const gimple *s, static inline range_operator * gimple_range_handler (const gimple *s) { - if ((gimple_code (s) == GIMPLE_ASSIGN) || (gimple_code (s) == GIMPLE_COND)) - return range_op_handler (gimple_expr_code (s), gimple_expr_type (s)); + if (gimple_code (s) == GIMPLE_ASSIGN) + return range_op_handler (gimple_assign_rhs_code (s), + TREE_TYPE (gimple_assign_lhs (s))); + if (gimple_code (s) == GIMPLE_COND) + return range_op_handler (gimple_cond_code (s), + TREE_TYPE (gimple_cond_lhs (s))); return NULL; } diff --git a/gcc/range-op.cc b/gcc/range-op.cc index aff9383d936..86d1af7fe54 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -3341,10 +3341,12 @@ pointer_table::pointer_table () range_operator * range_op_handler (enum tree_code code, tree type) { - // First check if there is apointer specialization. + // First check if there is a pointer specialization. if (POINTER_TYPE_P (type)) return pointer_tree_table[code]; - return integral_tree_table[code]; + if (INTEGRAL_TYPE_P (type)) + return integral_tree_table[code]; + return NULL; } // Cast the range in R to TYPE.