From patchwork Sat Dec 10 20:38:07 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 130564 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]) by ozlabs.org (Postfix) with SMTP id 0A1BEB6FF5 for ; Sun, 11 Dec 2011 07:38:28 +1100 (EST) Received: (qmail 26330 invoked by alias); 10 Dec 2011 20:38:26 -0000 Received: (qmail 26322 invoked by uid 22791); 10 Dec 2011 20:38:25 -0000 X-SWARE-Spam-Status: No, hits=-7.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 10 Dec 2011 20:38:09 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pBAKc8R6001345 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sat, 10 Dec 2011 15:38:08 -0500 Received: from pebble.twiddle.net (vpn-9-249.rdu.redhat.com [10.11.9.249]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id pBAKc7Ux027263 for ; Sat, 10 Dec 2011 15:38:08 -0500 Message-ID: <4EE3C32F.2050301@redhat.com> Date: Sat, 10 Dec 2011 12:38:07 -0800 From: Richard Henderson User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111115 Thunderbird/8.0 MIME-Version: 1.0 To: GCC Patches Subject: (Re)Define GET_MODE_2XWIDER_MODE for vectors X-IsSubscribed: yes 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 Previously, GET_MODE_2XWIDER_MODE had no specific definition for vector modes; yes you'd get _a_ type that contained twice as many bits, but usually nothing interesting. This allows me to remove a fixme from the i386 backend that has been there for years. I want to do this before introducing 3 more copies of this fixme as I add vect_perm_const support to more backends. Tested on x86_64-linux. r~ commit 3ebc6d778bb4dcae8047227b036515e47cc3fb04 Author: Richard Henderson Date: Fri Dec 9 15:12:31 2011 -0800 Let GET_MODE_2XWIDER_MODE find a double-width vector mode. * genmodes.c (struct mode_data): Remove wider_2x member. (blank_mode): Adjust initializer. (calc_wider_mode): Use XALLOCAVEC. (emit_move_wider): Select double-width same-element vectors for 2xwider vectors. * machmode.h (GET_MODE_2XWIDER_MODE): Update documentation. * config/i386/i386.c (doublesize_vector_mode): Remove. (expand_vselect_vconcat): Use GET_MODE_2XWIDER_MODE instead. diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 811ea31..3490874 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2011-12-10 Richard Henderson + + * genmodes.c (struct mode_data): Remove wider_2x member. + (blank_mode): Adjust initializer. + (calc_wider_mode): Use XALLOCAVEC. + (emit_move_wider): Select double-width same-element vectors for + 2xwider vectors. + * machmode.h (GET_MODE_2XWIDER_MODE): Update documentation. + * config/i386/i386.c (doublesize_vector_mode): Remove. + (expand_vselect_vconcat): Use GET_MODE_2XWIDER_MODE instead. + 2011-12-10 Joern Rennecke * config/epiphany/epiphany.h (USE_LOAD_POST_INCREMENT): Define. diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 15c6c37..216ab0b 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -35306,40 +35306,6 @@ ix86_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost, } } - -/* Return a vector mode with twice as many elements as VMODE. */ -/* ??? Consider moving this to a table generated by genmodes.c. */ - -static enum machine_mode -doublesize_vector_mode (enum machine_mode vmode) -{ - switch (vmode) - { - case V2SFmode: return V4SFmode; - case V1DImode: return V2DImode; - case V2SImode: return V4SImode; - case V4HImode: return V8HImode; - case V8QImode: return V16QImode; - - case V2DFmode: return V4DFmode; - case V4SFmode: return V8SFmode; - case V2DImode: return V4DImode; - case V4SImode: return V8SImode; - case V8HImode: return V16HImode; - case V16QImode: return V32QImode; - - case V4DFmode: return V8DFmode; - case V8SFmode: return V16SFmode; - case V4DImode: return V8DImode; - case V8SImode: return V16SImode; - case V16HImode: return V32HImode; - case V32QImode: return V64QImode; - - default: - gcc_unreachable (); - } -} - /* Construct (set target (vec_select op0 (parallel perm))) and return true if that's a valid instruction in the active ISA. */ @@ -35374,7 +35340,7 @@ expand_vselect_vconcat (rtx target, rtx op0, rtx op1, enum machine_mode v2mode; rtx x; - v2mode = doublesize_vector_mode (GET_MODE (op0)); + v2mode = GET_MODE_2XWIDER_MODE (GET_MODE (op0)); x = gen_rtx_VEC_CONCAT (v2mode, op0, op1); return expand_vselect (target, x, perm, nelt); } diff --git a/gcc/genmodes.c b/gcc/genmodes.c index dae7e38..8b6f5bc 100644 --- a/gcc/genmodes.c +++ b/gcc/genmodes.c @@ -63,7 +63,6 @@ struct mode_data struct mode_data *component; /* mode of components */ struct mode_data *wider; /* next wider mode */ - struct mode_data *wider_2x; /* 2x wider mode */ struct mode_data *contained; /* Pointer to list of modes that have this mode as a component. */ @@ -83,7 +82,7 @@ static struct mode_data *void_mode; static const struct mode_data blank_mode = { 0, "", MAX_MODE_CLASS, -1U, -1U, -1U, -1U, - 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, "", 0, 0, 0, 0 }; @@ -790,7 +789,7 @@ calc_wider_mode (void) /* Allocate max_n_modes + 1 entries to leave room for the extra null pointer assigned after the qsort call below. */ - sortbuf = (struct mode_data **) alloca ((max_n_modes + 1) * sizeof (struct mode_data *)); + sortbuf = XALLOCAVEC (struct mode_data *, max_n_modes + 1); for (c = 0; c < MAX_MODE_CLASS; c++) { @@ -804,7 +803,6 @@ calc_wider_mode (void) for (prev = 0, m = modes[c]; m; m = next) { m->wider = void_mode; - m->wider_2x = void_mode; /* this is nreverse */ next = m->next; @@ -827,7 +825,6 @@ calc_wider_mode (void) for (j = 0; j < i; j++) sortbuf[j]->next = sortbuf[j]->wider = sortbuf[j + 1]; - modes[c] = sortbuf[0]; } } @@ -1062,6 +1059,21 @@ emit_mode_wider (void) continue; } + /* For vectors we want twice the number of components, + with the same element type. */ + if (m->cl == MODE_VECTOR_INT + || m->cl == MODE_VECTOR_FLOAT + || m->cl == MODE_VECTOR_FRACT + || m->cl == MODE_VECTOR_UFRACT + || m->cl == MODE_VECTOR_ACCUM + || m->cl == MODE_VECTOR_UACCUM) + { + if (m2->ncomponents != 2 * m->ncomponents) + continue; + if (m->component != m2->component) + continue; + } + break; } if (m2 == void_mode) diff --git a/gcc/machmode.h b/gcc/machmode.h index b965d0f..4a3f6f5 100644 --- a/gcc/machmode.h +++ b/gcc/machmode.h @@ -221,6 +221,8 @@ extern const unsigned char mode_nunits[NUM_MACHINE_MODES]; extern const unsigned char mode_wider[NUM_MACHINE_MODES]; #define GET_MODE_WIDER_MODE(MODE) ((enum machine_mode) mode_wider[MODE]) +/* For scalars, this is a mode with twice the precision. For vectors, + this is a mode with the same inner mode but with twice the elements. */ extern const unsigned char mode_2xwider[NUM_MACHINE_MODES]; #define GET_MODE_2XWIDER_MODE(MODE) ((enum machine_mode) mode_2xwider[MODE])