From patchwork Tue Jan 28 16:52:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Stubbs X-Patchwork-Id: 1230437 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=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-518426-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha1 header.s=default header.b=yIvJ11Kk; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 486Xjt53fLz9sNx for ; Wed, 29 Jan 2020 03:53:05 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:message-id:date:mime-version:content-type; q=dns; s= default; b=XmijhfER4vt8VzVeGfIqNfOs3F4Gayuhza6ON6KQgE3F7aGg8UBCJ 4LLO8g+IA9Yw3brWVMZmlhQ7vijm4YAHrbCYlGEuLUIPPmp9jFoFngnk2zIvhvYX gU9GjIbWr/UVK8kttNuyP0CHXHTUO1GOwaBZmOoCEf/NASLeUjXr74= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:message-id:date:mime-version:content-type; s= default; bh=ty+oM19T9WxKcQvHRIrvHs3epXs=; b=yIvJ11KkF26hu/s29qGW OxBz7RNS6PtRfQ5/D8/WT3k01rTjplfyJb10iru2+6aP/rbSdzCZMI2AhO2cTIib xRy9bUQa1RDEjIuWmBNxs5ueKj4ebejURTP50VUIdUzjumQkP61HonsGhmwDe+Gd N1/rBHgO4YdZBN8UmXmqEoI= Received: (qmail 73112 invoked by alias); 28 Jan 2020 16:52:57 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 73069 invoked by uid 89); 28 Jan 2020 16:52:57 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=HX-Languages-Length:2161 X-HELO: esa3.mentor.iphmx.com Received: from esa3.mentor.iphmx.com (HELO esa3.mentor.iphmx.com) (68.232.137.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 28 Jan 2020 16:52:55 +0000 IronPort-SDR: JbGJ6W5djsDy0iKRQalTyX6qqb9XnbBTtG2c5/GSIbhjlNg/j97k1rTfQFfuZZW4piYTnLLF1M LehCfcyAEHXXkTGI4245xN98i+OAk5rgUS2/djDwXroGzpoN8hmUHrOg6yD1MP543YkhaUihbe MlsecA5okwB3Fasq//8aLB6i3Kd8RCwpDQdLioHUDRc8vvRMgpTuU/s5ftMZNmLUjhU7ktBEmq erlFyW8qzVoPnfJBPpzc3iIpuLfW9647vJY1/Ae2VZ83uB6OyyzsfKeJ0uyGkFB89V96j+IK7v FP4= Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa3.mentor.iphmx.com with ESMTP; 28 Jan 2020 08:52:54 -0800 IronPort-SDR: KtMrWNusKq6xxw/hNFzLwfOYmZ9XwGDFTROC7YKsw7Qla+Vq03WbC25h4UHRa2abBP/bDI579H Pe7pedTvdMiA== From: Andrew Stubbs Subject: [PATCH, ivopts] Fix fast-math-pr55281.c ICE To: "gcc-patches@gcc.gnu.org" Message-ID: Date: Tue, 28 Jan 2020 16:52:48 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 This patch fixes an ICE compiling fast-math-pr55281.c for amdgcn. The problem is that an "iv" is created in which both base and step are pointer types, but the base is converted to sizetype without also converting the step to a non-pointer type. Later in the compilation this results in a PLUS_EXPR with a pointer argument, which is invalid gimple. The patch fixes the problem by ensuring that the step is converted at the same point the base is. This seems like it ought to be correct. If the step is not a pointer type then no conversion occurs. I don't really understand why I only see this issue on amdgcn, but it might be because the pointer in question is in a MASK_LOAD which is perhaps not that commonly used? I've tested this on amdgcn, and done a full bootstrap and test on x86_64 also. OK to commit? Thanks Andrew Fix fast-math-pr55281.c ICE. 2020-01-28 Andrew Stubbs gcc/ * tree-ssa-loop-ivopts.c (add_iv_candidate_for_use): Convert step to basestep similarly to basetype. diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index a21f3077e74..1abeb13bb53 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -3472,7 +3472,7 @@ add_iv_candidate_for_use (struct ivopts_data *data, struct iv_use *use) { poly_uint64 offset; tree base; - tree basetype; + tree basetype, basestep; struct iv *iv = use->iv; add_candidate (data, iv->base, iv->step, false, use); @@ -3482,9 +3482,14 @@ add_iv_candidate_for_use (struct ivopts_data *data, struct iv_use *use) /* Record common candidate with initial value zero. */ basetype = TREE_TYPE (iv->base); + basestep = iv->step; if (POINTER_TYPE_P (basetype)) - basetype = sizetype; - record_common_cand (data, build_int_cst (basetype, 0), iv->step, use); + { + basetype = sizetype; + if (POINTER_TYPE_P (TREE_TYPE (iv->step))) + basestep = fold_convert (basetype, iv->step); + } + record_common_cand (data, build_int_cst (basetype, 0), basestep, use); /* Compare the cost of an address with an unscaled index with the cost of an address with a scaled index and add candidate if useful. */