From patchwork Mon Jun 17 16:11:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 251913 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id F14AE2C0174 for ; Tue, 18 Jun 2013 02:12:07 +1000 (EST) 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=GREppzVf6Npzw/b6EoHeBiM1vBGjm XJaZkTJyEXP0cUM/iBGLg1RLOU/Qsh8Unke51UWAPCvVOEJay7+TaZ78FitTcMfz tsMbCd9YgVOLqI23rWX1Xp6tbNAZcT+amlKbKhMlYPRfBJ3sJMEGy9GpdlW+A3Po v5MYVk7DV5kPsI= 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=Y1OdNNi7jMe/34SWXveGwTNctvQ=; b=AxK pRECLVAgxcmDVxMvrQkDe8YjsGc9nh7WxEi4HRIj5Rp9wg7uH+kyPIOBkmYGCy1b iqJGuHtGTcoHsGZ7nBg6inppbSFumQ04Jh5BZ0YyyfyCyJJv0jQmLWzJtNTsC3pj +f66f8wYKSXOAYNGbkducawc+OJ9tjVSeyrymKYs= Received: (qmail 22011 invoked by alias); 17 Jun 2013 16:12:00 -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 22002 invoked by uid 89); 17 Jun 2013 16:11:59 -0000 X-Spam-SWARE-Status: No, score=-6.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 17 Jun 2013 16:11:59 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r5HGBvCV009495 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 17 Jun 2013 12:11:57 -0400 Received: from zalov.cz (vpn-55-195.rdu2.redhat.com [10.10.55.195]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r5HGBuTb018437 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 17 Jun 2013 12:11:57 -0400 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.cz (8.14.5/8.14.5) with ESMTP id r5HGBsTi010253; Mon, 17 Jun 2013 18:11:55 +0200 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id r5HGBrWj010252; Mon, 17 Jun 2013 18:11:53 +0200 Date: Mon, 17 Jun 2013 18:11:52 +0200 From: Jakub Jelinek To: Uros Bizjak , Richard Henderson Cc: gcc-patches@gcc.gnu.org, Kirill Yukhin Subject: [PATCH] Fix up bmi_bextr_ (PR target/57623) Message-ID: <20130617161152.GZ2336@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Hi! This instruction has the predicates/constraints wrong, the r/m argument is the middle-one, the value from which it should be extracted, rather than the packed start/length argument. This got broken with PR50766, where the patch hasn't touched just BMI2, but for unknown reasons also this BMI instruction which was handled right in GCC 4.6. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/4.8/4.7? BTW, the AVX2 docs document _bextr_u{32,64} 3 argument intrinsics, rather than the __bextr_u{32,64} 2 argument intrinsics we have in GCC right now. Something to fix up (as the names are different, perhaps we can both the old ones and the new ones implemented say as return __bextr_u32 (x, (y & 255) | (z << 8)); or similar)? 2013-06-17 Jakub Jelinek PR target/57623 * config/i386/i386.md (bmi_bextr_): Swap predicates and constraints of operand 1 and 2. * gcc.target/i386/bmi-bextr-3.c: New test. Jakub --- gcc/config/i386/i386.md.jj 2013-06-09 20:29:02.000000000 +0200 +++ gcc/config/i386/i386.md 2013-06-15 18:24:48.942362202 +0200 @@ -11679,8 +11679,8 @@ (define_insn "*bmi_andn_" (define_insn "bmi_bextr_" [(set (match_operand:SWI48 0 "register_operand" "=r,r") - (unspec:SWI48 [(match_operand:SWI48 1 "register_operand" "r,r") - (match_operand:SWI48 2 "nonimmediate_operand" "r,m")] + (unspec:SWI48 [(match_operand:SWI48 1 "nonimmediate_operand" "r,m") + (match_operand:SWI48 2 "register_operand" "r,r")] UNSPEC_BEXTR)) (clobber (reg:CC FLAGS_REG))] "TARGET_BMI" --- gcc/testsuite/gcc.target/i386/bmi-bextr-3.c.jj 2013-06-17 09:48:47.789600664 +0200 +++ gcc/testsuite/gcc.target/i386/bmi-bextr-3.c 2013-06-17 09:48:37.000000000 +0200 @@ -0,0 +1,31 @@ +/* PR target/57623 */ +/* { dg-do assemble { target bmi } } */ +/* { dg-options "-O2 -mbmi" } */ + +#include + +unsigned int +f1 (unsigned int x, unsigned int *y) +{ + return __bextr_u32 (x, *y); +} + +unsigned int +f2 (unsigned int *x, unsigned int y) +{ + return __bextr_u32 (*x, y); +} + +#ifdef __x86_64__ +unsigned long long +f3 (unsigned long long x, unsigned long long *y) +{ + return __bextr_u64 (x, *y); +} + +unsigned long long +f4 (unsigned long long *x, unsigned long long y) +{ + return __bextr_u64 (*x, y); +} +#endif