From patchwork Sat Dec 30 19:27:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 854146 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-469910-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Kxvq54lk"; 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 3z8D4z2y4Gz9s7s for ; Sun, 31 Dec 2017 06:28:00 +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; q=dns; s=default; b=ZPi06jBPxA3EDEBUIAgTHXCyMNT04 cUz8yv+Zq8EYC3AdCoWGZCBUnB4nQ7zAXktd9xVB/1QWlcthmtHafpSLU1286K28 zmIHU1FkaHMnwsRUc0LgVQ569QWlnFoHTIvpq6K3etXjl2UcjlvUKPYXvsaXtYjm Rc71aoJlJmStAo= 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; s=default; bh=+YFb85wApz2LyRYfTIpClCaa9Dk=; b=Kxv q54lkjsEP7Lp0HEhVDw+D4SqzkKAQNRNjSSNjecTpi14DnSf++92Ghf2O37AtS/v PJVK+QdGw2o3OnOZAVT7ELyJLocB8kiu/XnD/30H/otD5S8H6/V6LkbxQTu5XkOc VSHSDNpOCvrVURqJkFw1tehb6XEjiS9bsFI8OHM4= Received: (qmail 107234 invoked by alias); 30 Dec 2017 19:27:54 -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 107224 invoked by uid 89); 30 Dec 2017 19:27:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 30 Dec 2017 19:27:52 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2CD802D26A5; Sat, 30 Dec 2017 19:27:51 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-90.ams2.redhat.com [10.36.116.90]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B289A6061B; Sat, 30 Dec 2017 19:27:50 +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 vBUJRluO023176; Sat, 30 Dec 2017 20:27:47 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id vBUJRirV023175; Sat, 30 Dec 2017 20:27:44 +0100 Date: Sat, 30 Dec 2017 20:27:44 +0100 From: Jakub Jelinek To: Richard Biener , Jeff Law Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix ICE with vector 16-bit rotate (PR middle-end/83623) Message-ID: <20171230192744.GM1833@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.1 (2017-09-22) X-IsSubscribed: yes Hi! Ths chunk of code wants to expand 16-bit rotate by 8 as bswaphi, but if mode is a vector mode (or complex mode), trying to use bswaphi pattern to swap say V16HImode vector is just wrong. This patch arranges to use bswapv16hi etc. instead in those cases, which isn't 100% clear to me from the docs if they only swap bytes of each of the vector element, but from looking at a few backends it seems like that is the case and if it wasn't, e.g. simplify-rtx.c would missimplify stuff. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2017-12-30 Jakub Jelinek PR middle-end/83623 * expmed.c (expand_shift_1): For 2-byte rotates by BITS_PER_UNIT, check for bswap in mode rather than HImode and use that in expand_unop too. * gcc.dg/pr83623.c: New test. Jakub --- gcc/expmed.c.jj 2017-12-20 20:40:18.000000000 +0100 +++ gcc/expmed.c 2017-12-30 11:44:47.045433528 +0100 @@ -2490,9 +2490,8 @@ expand_shift_1 (enum tree_code code, mac && CONST_INT_P (op1) && INTVAL (op1) == BITS_PER_UNIT && GET_MODE_SIZE (scalar_mode) == 2 - && optab_handler (bswap_optab, HImode) != CODE_FOR_nothing) - return expand_unop (HImode, bswap_optab, shifted, NULL_RTX, - unsignedp); + && optab_handler (bswap_optab, mode) != CODE_FOR_nothing) + return expand_unop (mode, bswap_optab, shifted, NULL_RTX, unsignedp); if (op1 == const0_rtx) return shifted; --- gcc/testsuite/gcc.dg/pr83623.c.jj 2017-12-30 11:49:23.259470538 +0100 +++ gcc/testsuite/gcc.dg/pr83623.c 2017-12-30 11:49:01.309467592 +0100 @@ -0,0 +1,12 @@ +/* PR middle-end/83623 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-mmovbe" { target i?86-*-* x86_64-*-* } } */ + +unsigned short __attribute__ ((__vector_size__ (16))) x; + +void +foo (void) +{ + x = x << 8 | x >> 8; +}