From patchwork Tue Dec 10 20:54:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1207282 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-515650-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="VUx0oFAs"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="MtohAW0b"; 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 47XXP05kfLz9sPK for ; Wed, 11 Dec 2019 07:54:26 +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:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=d8I 0ToFeUP+K5ajKoJHL4ixCxW/7RUkJE7VaRMj6WVr2Ff7/k4cRHqkMixXWR9J97Kv Y7QS2Yp3KPdruFHuazN7uDz6weuNc78WF0zqGqeq0+DWkpYTSwRPn6l66aGIgniL 5FSUeTwcATBW3dsyO/bWrDB98ICMhztj/Oy1XcS0= 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:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type:content-transfer-encoding; s=default; bh=q4A1S+wZ5 fX8h6C3DIo7xw781F4=; b=VUx0oFAs8KcHmhNhYToMvMr1SrNtFrYb9zK08LpAm qr9dLGfErmIWMr+uU/T0NWptk7vInWfkkWUONcIlL6SJzQRL8JopRb9HYM2cBGdQ eGqCWYQZqnIBAU1oSiI1zvWYm4oqQNAJ24dC1taKpZ0cSBnRoOT0sMocwN867Wl8 Yc= Received: (qmail 29027 invoked by alias); 10 Dec 2019 20:54:19 -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 29020 invoked by uid 89); 10 Dec 2019 20:54:19 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-7.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy= X-HELO: us-smtp-1.mimecast.com Received: from us-smtp-delivery-1.mimecast.com (HELO us-smtp-1.mimecast.com) (205.139.110.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 10 Dec 2019 20:54:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576011256; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZexFvLje6TOC01yEtOTLxRnQRcP28aiKqu3cwWq0HoU=; b=MtohAW0bEhaycpW/N+X4YKj0kfhIoWBTk5O5D6GBH5I3jVklV2ugZmckIGTvXdryP4V6t2 B3PWzw6T/0ufKdnS1kfFxkciuROID8SvNQyJKSwnmCaEuS3itcgBxqu/M4rBMgtA26Fieo Lihr9+CbvDFXzl2lskMUUDDQ4ToSn8Y= 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-158-DcK9quHVP4ex_qeBOjw6Xg-1; Tue, 10 Dec 2019 15:54:10 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6DF8D1005512; Tue, 10 Dec 2019 20:54:09 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-117-59.ams2.redhat.com [10.36.117.59]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0E5D45C1B0; Tue, 10 Dec 2019 20:54:08 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id xBAKs6Bm007323; Tue, 10 Dec 2019 21:54:06 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id xBAKs5Og007322; Tue, 10 Dec 2019 21:54:05 +0100 Date: Tue, 10 Dec 2019 21:54:05 +0100 From: Jakub Jelinek To: Richard Biener , Richard Sandiford Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix vect rotate pattern recog (PR target/92723) Message-ID: <20191210205405.GG10088@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 User-Agent: Mutt/1.11.3 (2019-02-01) X-Mimecast-Spam-Score: 0 Content-Disposition: inline X-IsSubscribed: yes Hi! Unlike x86, where the last operand of vector by scalar shift is DImode for V[248]DImode shifts, on aarch64 they seem to be SImode. vect_recog_rotate_pattern when the rotate amount is not constant casts the amount to the element type of the vector, so for V[248]DImode vectors to DImode, but then we ICE during expand_shift_1 because such argument doesn't satisfy the predicate and can't be widened to it. The following patch fixes it by special casing vector by scalar shifts when adding patterns for rotates, in that case we punt if the operand isn't INTEGER_CST or external_def, and the patch just keeps using the type of the amount operand the rotate had for the shifts too. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2019-12-10 Jakub Jelinek PR target/92723 * tree-vect-patterns.c (vect_recog_rotate_pattern): If vector x vector shifts aren't supported and rotate amount is SSA_NAME, use its type rather than first operand's type for the shift amounts. * gcc.dg/vect/pr92723.c: New test. Jakub --- gcc/tree-vect-patterns.c.jj 2019-12-09 11:12:29.983288823 +0100 +++ gcc/tree-vect-patterns.c 2019-12-10 16:30:59.922177911 +0100 @@ -2242,6 +2242,7 @@ vect_recog_rotate_pattern (stmt_vec_info optab optab1, optab2; edge ext_def = NULL; bool bswap16_p = false; + bool scalar_shift_p = false; if (is_gimple_assign (last_stmt)) { @@ -2420,6 +2421,7 @@ vect_recog_rotate_pattern (stmt_vec_info || !optab2 || optab_handler (optab2, TYPE_MODE (vectype)) == CODE_FOR_nothing) return NULL; + scalar_shift_p = true; } *type_out = vectype; @@ -2439,7 +2441,8 @@ vect_recog_rotate_pattern (stmt_vec_info def = NULL_TREE; scalar_int_mode mode = SCALAR_INT_TYPE_MODE (type); if (TREE_CODE (oprnd1) == INTEGER_CST - || TYPE_MODE (TREE_TYPE (oprnd1)) == mode) + || TYPE_MODE (TREE_TYPE (oprnd1)) == mode + || scalar_shift_p) def = oprnd1; else if (def_stmt && gimple_assign_cast_p (def_stmt)) { --- gcc/testsuite/gcc.dg/vect/pr92723.c.jj 2019-12-10 16:37:09.924375698 +0100 +++ gcc/testsuite/gcc.dg/vect/pr92723.c 2019-12-10 16:37:21.823189103 +0100 @@ -0,0 +1,9 @@ +/* { dg-do compile } */ + +void +foo (unsigned long long *x, unsigned long long *y, int z) +{ + int i; + for (i = 0; i < 1024; i++) + x[i] = (y[i] >> z) | (y[i] << (-z & (__SIZEOF_LONG_LONG__ * __CHAR_BIT__ - 1))); +}