From patchwork Fri Jan 26 13:31:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 125970 Delivered-To: patch@linaro.org Received: by 10.46.84.92 with SMTP id y28csp337142ljd; Fri, 26 Jan 2018 05:31:30 -0800 (PST) X-Google-Smtp-Source: AH8x224ONe2BbSvlTMBC57V8KGVc0jOATJLHavlY5ptE4x0jY+1gFnANQbLxuw/oe7dHCc/saCNW X-Received: by 10.98.139.8 with SMTP id j8mr19394476pfe.4.1516973489938; Fri, 26 Jan 2018 05:31:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516973489; cv=none; d=google.com; s=arc-20160816; b=TC2ICP1d2DssSmqsqgLwhTTB06no/EWcwUWepheCcZ7iMHzgg0XCPoM5qAhjBS9G5T XH+JEhh6xjnWEb6IBYzJdf+y0T1C+YBue41rzoONUeqiGlMRl2+b3LDHPlEBsQ9hGtZG J3dvSQ3DtHOAUSVKoQvPsjf238lY/pgF8AAd5IrIA25RQqdDfRGfmUrb/xpUwmErW3kl xP7cLMv/ThaA3x4oJrM39MqY7D4Igz9KjS9BlDdX8pU6wEPHGM+Ytl6kOWER532OEiyt 0ofDL8VxIV2l9lf0O5v9yBQvZ5c2PnQvuEL/rtswdOt1Rj7BWKbi8Shegr2KIA1S4/hk 3KfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:date:subject:cc: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=MqTI89qM9MKW3wj48Hu1hnQrEqmDlJ6OzYuWL+N3JKU=; b=DSn7QYmYxGCkNk8qIa2t3gbfnWAKTGDtK/8nxAM+TARfAO/SkusaGvZUDy52PIITz5 i1UYyx119BBjs1O0lOavQTb/lR6DNTMM+NVe0Zrq2F+eUydL9OvEiUc+sC+Usm9AgHWJ KtqXKACXA7UCA5ZpLI5OVpE0GxVE5N+3PiR/rxdsdB1CrFxr8PwSZ1Ma3MqbP8nO+wPr IvfQfXc8z65Uyvb5/SeN9b3ChwSWFSh2HtMDIj+Cok2jAY3LypEM/hx/0zvfsH52m8wz BygJ1WFxXOp+t/SR3SRaXjbIF8WuGc+bNBtV53Z1Znn3CbZsG7Jky/LfzDOIW6cHN60B jL4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=e33486lc; spf=pass (google.com: domain of gcc-patches-return-472099-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-472099-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 b10si3019559pgr.765.2018.01.26.05.31.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Jan 2018 05:31:29 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-472099-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=e33486lc; spf=pass (google.com: domain of gcc-patches-return-472099-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-472099-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:cc:subject:date:message-id:mime-version:content-type; q=dns; s=default; b=NeXzIwggXXaxeDJODQWZd38tlGwxykPEVUKbwTR4mbVZ5FBSge m0gP6ZB/GG7wQI2cxpNdAePRlHqbXw2c0uW1woXBhTAgzEG8ndl1UaGzUabfZ7WU ENjMHnBsNRUpdopKZxyZ7qAgo9hUiLq6sHgU/5DSq6gql++nV4+LyNqpQ= 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:cc:subject:date:message-id:mime-version:content-type; s= default; bh=eLqm2gM6X5ZvAtIE4l9tmbWC0cg=; b=e33486lcPMW68BC4mBVE 5km+zsANqg0tnXl666fMcADCPsLfIlC/c4LpDnH48cvHuDhUgFHJQB7gIzYpB+AP mZdA6SFy0yW4GsT0mzhL33/iHdrfSjoOEqYIKusOYf9Vy/sZx3PGcjoN85woM/JT ofA0BKJiFrHlK4z+7/c+f7s= Received: (qmail 3720 invoked by alias); 26 Jan 2018 13:31:16 -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 3671 invoked by uid 89); 26 Jan 2018 13:31:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=VEL, vel, Hx-languages-length:3713 X-HELO: mail-wr0-f180.google.com Received: from mail-wr0-f180.google.com (HELO mail-wr0-f180.google.com) (209.85.128.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 26 Jan 2018 13:31:05 +0000 Received: by mail-wr0-f180.google.com with SMTP id i56so542283wra.7 for ; Fri, 26 Jan 2018 05:31:05 -0800 (PST) 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:cc:subject:date :message-id:user-agent:mime-version; bh=MqTI89qM9MKW3wj48Hu1hnQrEqmDlJ6OzYuWL+N3JKU=; b=l/ww2AVzTdQ93WAHG4nUT6qvYNppRg97+gN1Fh3w4u+9+0yj+8k7I48WV2bL7i8RmZ Yg9K1/BQ9dyjgSbStT+udz6nmRhf/0TdbkRYibCMNQifg66zwLD8RtJoTorxJfLqg8j2 Lu7Ncw0BgCCHQH10q3C7KjDNyJfoqqHrc3v93gy71fl9QtGT/IdMuQkWsoTTcbCEMxmQ zw+0vGt5PVc0W7c3y2OUryz/5tz3k+iTgEWj/RWomjQ81vz2cZDtIdGyxPlNpbi+obqZ M63AXTyKLJ8nIFja00A7+O1htnrjINyh2RYjp/sb/BDqAUlVbqhYlUs9fgalgDu+2YvX AnXg== X-Gm-Message-State: AKwxytcV+Z2/cl6KLZ2SzKy30QeEfxt0MbhKHr8lyGMCTmfL6GJ+ETgf lNuykTpZEKZuEeAuVc3ouQ5ywA== X-Received: by 10.223.161.29 with SMTP id o29mr12743360wro.2.1516973463226; Fri, 26 Jan 2018 05:31:03 -0800 (PST) Received: from localhost (92.40.248.158.threembb.co.uk. [92.40.248.158]) by smtp.gmail.com with ESMTPSA id c49sm5303796wrc.48.2018.01.26.05.31.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 26 Jan 2018 05:31:02 -0800 (PST) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.earnshaw@arm.com, james.greenhalgh@arm.com, marcus.shawcroft@arm.com, richard.sandiford@linaro.org Cc: richard.earnshaw@arm.com, james.greenhalgh@arm.com, marcus.shawcroft@arm.com Subject: [AArch64] Fix sve/extract_[12].c for big-endian SVE Date: Fri, 26 Jan 2018 13:31:00 +0000 Message-ID: <87d11wpx0r.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 sve/extract_[12].c were relying on the target-independent optimisation that removes a redundant vec_select, so that we don't end up with things like: dup v0.4s, v0.4s[0] ...use s0... But that optimisation rightly doesn't trigger for big-endian targets, because GCC expects lane 0 to be in the high part of the register rather than the low part. SVE breaks this assumption -- see the comment at the head of aarch64-sve.md for details -- so the optimisation is valid for both endiannesses. Long term, we probably need some kind of target hook to make GCC aware of this. But there's another problem with the current extract pattern: it doesn't tell the register allocator how cheap an extraction of lane 0 is with tied registers. It seems better to split the lane 0 case out into its own pattern and use tied operands for the FPR<-SIMD case, so that using different registers has the cost of an extra reload. I think we want this for both endiannesses, regardless of the hook described above. Also, the gen_lowpart in this pattern fails for aarch64_be due to TARGET_CAN_CHANGE_MODE_CLASS restrictions, so the patch uses gen_rtx_REG instead. We're only creating this rtl in order to print it, so there's no need for anything fancier. Tested on aarch64_be-elf and aarch64-linux-gnu. OK to install? Richard 2018-01-26 Richard Sandiford gcc/ * config/aarch64/aarch64-sve.md (*vec_extract_0): New pattern. (*vec_extract_v128): Require a nonzero lane number. Use gen_rtx_REG rather than gen_lowpart. Index: gcc/config/aarch64/aarch64-sve.md =================================================================== --- gcc/config/aarch64/aarch64-sve.md 2018-01-13 18:01:51.232735405 +0000 +++ gcc/config/aarch64/aarch64-sve.md 2018-01-26 13:26:50.176756711 +0000 @@ -484,18 +484,52 @@ (define_expand "vec_extract" } ) +;; Extract element zero. This is a special case because we want to force +;; the registers to be the same for the second alternative, and then +;; split the instruction into nothing after RA. +(define_insn_and_split "*vec_extract_0" + [(set (match_operand: 0 "aarch64_simd_nonimmediate_operand" "=r, w, Utv") + (vec_select: + (match_operand:SVE_ALL 1 "register_operand" "w, 0, w") + (parallel [(const_int 0)])))] + "TARGET_SVE" + { + operands[1] = gen_rtx_REG (mode, REGNO (operands[1])); + switch (which_alternative) + { + case 0: + return "umov\\t%0, %1.[0]"; + case 1: + return "#"; + case 2: + return "st1\\t{%1.}[0], %0"; + default: + gcc_unreachable (); + } + } + "&& reload_completed + && REG_P (operands[1]) + && REGNO (operands[0]) == REGNO (operands[1])" + [(const_int 0)] + { + emit_note (NOTE_INSN_DELETED); + DONE; + } + [(set_attr "type" "neon_to_gp_q, untyped, neon_store1_one_lane_q")] +) + ;; Extract an element from the Advanced SIMD portion of the register. ;; We don't just reuse the aarch64-simd.md pattern because we don't -;; want any chnage in lane number on big-endian targets. +;; want any change in lane number on big-endian targets. (define_insn "*vec_extract_v128" [(set (match_operand: 0 "aarch64_simd_nonimmediate_operand" "=r, w, Utv") (vec_select: (match_operand:SVE_ALL 1 "register_operand" "w, w, w") (parallel [(match_operand:SI 2 "const_int_operand")])))] "TARGET_SVE - && IN_RANGE (INTVAL (operands[2]) * GET_MODE_SIZE (mode), 0, 15)" + && IN_RANGE (INTVAL (operands[2]) * GET_MODE_SIZE (mode), 1, 15)" { - operands[1] = gen_lowpart (mode, operands[1]); + operands[1] = gen_rtx_REG (mode, REGNO (operands[1])); switch (which_alternative) { case 0: