From patchwork Mon Oct 23 17:40:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 116845 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp4903699qgn; Mon, 23 Oct 2017 10:41:05 -0700 (PDT) X-Received: by 10.84.209.164 with SMTP id y33mr8411750plh.439.1508780465537; Mon, 23 Oct 2017 10:41:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508780465; cv=none; d=google.com; s=arc-20160816; b=fNtnfuY+w0udvr2kuwTGBi1339gg4xeC5UPq6l5EnaLHavHnJXz/wLNF4cBcvIUhlF PhOqIP7qjZ/amoOOeSbyp8ZhF+iJHAo97q/Xzc5Jec6Q8zm1R/9wRZqo5H9kWbtmeKqB N5u0vpkzi0L0dYQG3xogR7xmbHuVLZx0tpmis39wuw3eErDB/B58ZaUaFE3YHCqex+3F 0IHq0LlhjX1o42KZ3UBvh5CCaovStjQ0apoaUmCcguHFJIRKYZeFSFrGbooPUSKFm+vy Ae+zc1l/Vxef2MgDxrDvTZYcOgCnUOjrs2QsdRqT7Twkg3/Z9XmlHOncHrWy8rsqQQ+h AScw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:mail-followup-to:to:from:delivered-to:sender:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=uuPJeAEAUJ2W4pvlp6w1er2kG5xK7qKaqK8ihQ4Dj9A=; b=dFkX7Hk1/J2njeuArX2uw7p52ijAHPIFtN+TinI8sEACN7tKnBtTSIMNYP1BlIycps YG7/ddkdEPYPOGgi7uaJiZje+dKNz4ua+462WxMZSRgEpLfGyfnT1mYcZ4P358DY5F+/ kep/d0aDkS2tDCWLGeO52XJCSU7G/YoNzPNHi7GlTbnDG39huMZ/oI+KJDH8DNWj/EMg Q4Daxmm8GnIZISF+QBlX2j/pl4vAX3RI6OOZy2GRBKfuABfuKSKfx4MGkcSoXUVyDlmd B707RH/zyfJNs7QUJcBcsFhotMSrmgUi1Y2g3+BT4xwx1Wm+cjkem/fpTBn+ymtDZFu6 5aKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=xz8ihO1p; spf=pass (google.com: domain of gcc-patches-return-464876-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464876-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id 125si5151957pgj.752.2017.10.23.10.41.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Oct 2017 10:41:05 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-464876-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=xz8ihO1p; spf=pass (google.com: domain of gcc-patches-return-464876-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464876-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=default; b=AEotwyidGT/RUEtfMbuH9iP+aYqtC uygeMS9oXxRJMCQEbQCb5Tar34F6g1dFglRr60qlL44YsDJ2N8w8qwRaDh8/aa1Q sYbysvSBxttXa0ADwGU/kzKDXJxjkkr7YKbigEFkAAbwzLlLwQTu7RpJjlgfL4GS lWDYDXBeQZeJS0= 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 :to:subject:references:date:in-reply-to:message-id:mime-version :content-type; s=default; bh=ZLTRylPhBFDRWI5hZYhqA12wsNc=; b=xz8 ihO1pAOFx5OEMZa1dwJWy3SL8Js+kGKB3njBlgYsuQQVN/s87zoiDJZh9fwZWBhx aoUNli8b7j9TDvnH5yrDEzbHGOJMlnV3qu7umfQBjIpK2k91naA6KpC8DbK7drji QF0vbHMk3Ckb1DInYUhFRTyUzpSKX6wQSeetmpcU= Received: (qmail 121079 invoked by alias); 23 Oct 2017 17:40:52 -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 121067 invoked by uid 89); 23 Oct 2017 17:40:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f65.google.com Received: from mail-wm0-f65.google.com (HELO mail-wm0-f65.google.com) (74.125.82.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 23 Oct 2017 17:40:50 +0000 Received: by mail-wm0-f65.google.com with SMTP id r68so11402352wmr.3 for ; Mon, 23 Oct 2017 10:40:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:mail-followup-to:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=uuPJeAEAUJ2W4pvlp6w1er2kG5xK7qKaqK8ihQ4Dj9A=; b=DYVrZxVdR2FHodiiCFg7wi17bn8sOFJ4ru1lwrjvsGx+mK9s7dtMYOlO1pnkP1Dfma TNF2ar99By/NhrmNvg2CSsvopaCOxUIcpjYM0d+MuhZiVg7Zr7WZs8/kKZafi6aslDTW qXobcm2mELrLXt7zHktA0ncBOOg3Qfzoqbv2Tws6TTrU5kqkoBA0ClUyQ5Mnhx0ZtOVK g4bEjXkjzD24f3D/Q5lgXdIvMxuIIkbmfzWdl6dHHtAdq+thYl5B99xiYiZRJiC9Y8w6 J1PkTxiXla5/FNoMrmp8lBrhmNkdbaNa9ADvgz5uh1k6kfronaIT5aAv+a4ITRmjn5TC Nv2g== X-Gm-Message-State: AMCzsaVBX7krsaMDIb8klbrAV7OBRdI+NWqogt66pnvSmFDNgrhal1qu pTNaa5nOfbD4Rmy0zmMmZzy6oinSxHA= X-Google-Smtp-Source: ABhQp+Sc0HodHOiftS57D4Q65yJSx+pJdLsgK07mY2DtokyQfBzPJTObOygI9qaYPc9f0V7qBCpEwA== X-Received: by 10.28.63.68 with SMTP id m65mr5391206wma.55.1508780447990; Mon, 23 Oct 2017 10:40:47 -0700 (PDT) Received: from localhost ([2.26.27.199]) by smtp.gmail.com with ESMTPSA id v78sm3133499wmv.48.2017.10.23.10.40.46 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Oct 2017 10:40:47 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [100/nnn] poly_int: memrefs_conflict_p References: <871sltvm7r.fsf@linaro.org> Date: Mon, 23 Oct 2017 18:40:46 +0100 In-Reply-To: <871sltvm7r.fsf@linaro.org> (Richard Sandiford's message of "Mon, 23 Oct 2017 17:54:32 +0100") Message-ID: <87she9daox.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 The xsize and ysize arguments to memrefs_conflict_p are encode such that: - 0 means the size is unknown - >0 means the size is known - <0 means that the negative of the size is a worst-case size after alignment In other words, the sign effectively encodes a boolean; it isn't meant to be taken literally. With poly_ints these correspond to: - known_zero (...) - may_gt (..., 0) - may_lt (..., 0) respectively. 2017-10-23 Richard Sandiford Alan Hayward David Sherwood gcc/ * alias.c (addr_side_effect_eval): Take the size as a poly_int64 rather than an int. Use plus_constant. (memrefs_conflict_p): Take the sizes as poly_int64s rather than ints. Take the offset "c" as a poly_int64 rather than a HOST_WIDE_INT. Index: gcc/alias.c =================================================================== --- gcc/alias.c 2017-10-23 17:16:50.356530167 +0100 +++ gcc/alias.c 2017-10-23 17:25:47.476533124 +0100 @@ -148,7 +148,6 @@ struct GTY(()) alias_set_entry { }; static int rtx_equal_for_memref_p (const_rtx, const_rtx); -static int memrefs_conflict_p (int, rtx, int, rtx, HOST_WIDE_INT); static void record_set (rtx, const_rtx, void *); static int base_alias_check (rtx, rtx, rtx, rtx, machine_mode, machine_mode); @@ -2295,9 +2294,9 @@ get_addr (rtx x) is not modified by the memory reference then ADDR is returned. */ static rtx -addr_side_effect_eval (rtx addr, int size, int n_refs) +addr_side_effect_eval (rtx addr, poly_int64 size, int n_refs) { - int offset = 0; + poly_int64 offset = 0; switch (GET_CODE (addr)) { @@ -2318,11 +2317,7 @@ addr_side_effect_eval (rtx addr, int siz return addr; } - if (offset) - addr = gen_rtx_PLUS (GET_MODE (addr), XEXP (addr, 0), - gen_int_mode (offset, GET_MODE (addr))); - else - addr = XEXP (addr, 0); + addr = plus_constant (GET_MODE (addr), XEXP (addr, 0), offset); addr = canon_rtx (addr); return addr; @@ -2372,7 +2367,8 @@ offset_overlap_p (poly_int64 c, poly_int If that is fixed the TBAA hack for union type-punning can be removed. */ static int -memrefs_conflict_p (int xsize, rtx x, int ysize, rtx y, HOST_WIDE_INT c) +memrefs_conflict_p (poly_int64 xsize, rtx x, poly_int64 ysize, rtx y, + poly_int64 c) { if (GET_CODE (x) == VALUE) { @@ -2417,13 +2413,13 @@ memrefs_conflict_p (int xsize, rtx x, in else if (GET_CODE (x) == LO_SUM) x = XEXP (x, 1); else - x = addr_side_effect_eval (x, abs (xsize), 0); + x = addr_side_effect_eval (x, may_lt (xsize, 0) ? -xsize : xsize, 0); if (GET_CODE (y) == HIGH) y = XEXP (y, 0); else if (GET_CODE (y) == LO_SUM) y = XEXP (y, 1); else - y = addr_side_effect_eval (y, abs (ysize), 0); + y = addr_side_effect_eval (y, may_lt (ysize, 0) ? -ysize : ysize, 0); if (GET_CODE (x) == SYMBOL_REF && GET_CODE (y) == SYMBOL_REF) { @@ -2436,7 +2432,7 @@ memrefs_conflict_p (int xsize, rtx x, in through alignment adjustments (i.e., that have negative sizes), because we can't know how far they are from each other. */ - if (xsize < 0 || ysize < 0) + if (may_lt (xsize, 0) || may_lt (ysize, 0)) return -1; /* If decls are different or we know by offsets that there is no overlap, we win. */ @@ -2467,6 +2463,7 @@ memrefs_conflict_p (int xsize, rtx x, in else if (x1 == y) return memrefs_conflict_p (xsize, x0, ysize, const0_rtx, c); + poly_int64 cx1, cy1; if (GET_CODE (y) == PLUS) { /* The fact that Y is canonicalized means that this @@ -2483,22 +2480,21 @@ memrefs_conflict_p (int xsize, rtx x, in return memrefs_conflict_p (xsize, x0, ysize, y0, c); if (rtx_equal_for_memref_p (x0, y0)) return memrefs_conflict_p (xsize, x1, ysize, y1, c); - if (CONST_INT_P (x1)) + if (poly_int_rtx_p (x1, &cx1)) { - if (CONST_INT_P (y1)) + if (poly_int_rtx_p (y1, &cy1)) return memrefs_conflict_p (xsize, x0, ysize, y0, - c - INTVAL (x1) + INTVAL (y1)); + c - cx1 + cy1); else - return memrefs_conflict_p (xsize, x0, ysize, y, - c - INTVAL (x1)); + return memrefs_conflict_p (xsize, x0, ysize, y, c - cx1); } - else if (CONST_INT_P (y1)) - return memrefs_conflict_p (xsize, x, ysize, y0, c + INTVAL (y1)); + else if (poly_int_rtx_p (y1, &cy1)) + return memrefs_conflict_p (xsize, x, ysize, y0, c + cy1); return -1; } - else if (CONST_INT_P (x1)) - return memrefs_conflict_p (xsize, x0, ysize, y, c - INTVAL (x1)); + else if (poly_int_rtx_p (x1, &cx1)) + return memrefs_conflict_p (xsize, x0, ysize, y, c - cx1); } else if (GET_CODE (y) == PLUS) { @@ -2512,8 +2508,9 @@ memrefs_conflict_p (int xsize, rtx x, in if (x == y1) return memrefs_conflict_p (xsize, const0_rtx, ysize, y0, c); - if (CONST_INT_P (y1)) - return memrefs_conflict_p (xsize, x, ysize, y0, c + INTVAL (y1)); + poly_int64 cy1; + if (poly_int_rtx_p (y1, &cy1)) + return memrefs_conflict_p (xsize, x, ysize, y0, c + cy1); else return -1; } @@ -2537,11 +2534,11 @@ memrefs_conflict_p (int xsize, rtx x, in return offset_overlap_p (c, xsize, ysize); /* Can't properly adjust our sizes. */ - if (!CONST_INT_P (x1)) + if (!CONST_INT_P (x1) + || !can_div_trunc_p (xsize, INTVAL (x1), &xsize) + || !can_div_trunc_p (ysize, INTVAL (x1), &ysize) + || !can_div_trunc_p (c, INTVAL (x1), &c)) return -1; - xsize /= INTVAL (x1); - ysize /= INTVAL (x1); - c /= INTVAL (x1); return memrefs_conflict_p (xsize, x0, ysize, y0, c); } @@ -2562,9 +2559,9 @@ memrefs_conflict_p (int xsize, rtx x, in unsigned HOST_WIDE_INT uc = sc; if (sc < 0 && pow2_or_zerop (-uc)) { - if (xsize > 0) + if (may_gt (xsize, 0)) xsize = -xsize; - if (xsize) + if (maybe_nonzero (xsize)) xsize += sc + 1; c -= sc + 1; return memrefs_conflict_p (xsize, canon_rtx (XEXP (x, 0)), @@ -2577,9 +2574,9 @@ memrefs_conflict_p (int xsize, rtx x, in unsigned HOST_WIDE_INT uc = sc; if (sc < 0 && pow2_or_zerop (-uc)) { - if (ysize > 0) + if (may_gt (ysize, 0)) ysize = -ysize; - if (ysize) + if (maybe_nonzero (ysize)) ysize += sc + 1; c += sc + 1; return memrefs_conflict_p (xsize, x, @@ -2589,9 +2586,10 @@ memrefs_conflict_p (int xsize, rtx x, in if (CONSTANT_P (x)) { - if (CONST_INT_P (x) && CONST_INT_P (y)) + poly_int64 cx, cy; + if (poly_int_rtx_p (x, &cx) && poly_int_rtx_p (y, &cy)) { - c += (INTVAL (y) - INTVAL (x)); + c += cy - cx; return offset_overlap_p (c, xsize, ysize); } @@ -2613,7 +2611,9 @@ memrefs_conflict_p (int xsize, rtx x, in sizes), because we can't know how far they are from each other. */ if (CONSTANT_P (y)) - return (xsize < 0 || ysize < 0 || offset_overlap_p (c, xsize, ysize)); + return (may_lt (xsize, 0) + || may_lt (ysize, 0) + || offset_overlap_p (c, xsize, ysize)); return -1; }