Patchwork [i386] Introduce a flag to generate only 128-bit avx instructions

login
register
mail settings
Submitter Fang, Changpeng
Date March 2, 2011, 5:39 p.m.
Message ID <D4C76825A6780047854A11E93CDE84D004D8EE1F56@SAUSEXMBP01.amd.com>
Download mbox | patch
Permalink /patch/85116/
State New
Headers show

Comments

Fang, Changpeng - March 2, 2011, 5:39 p.m.
Modified following Jakub's suggestions.

Is it OK to commit to trunk?

Thanks,

Changpeng
Richard Henderson - March 2, 2011, 9:50 p.m.
On 03/03/2011 03:39 AM, Fang, Changpeng wrote:
>      case SFmode:
> -      return TARGET_AVX ? V8SFmode : V4SFmode;
> +      return (TARGET_AVX && !flag_avx_m128_only) ? V8SFmode : V4SFmode;
>      case DFmode:
> -      return TARGET_AVX ? V4DFmode : V2DFmode;
> +      return (TARGET_AVX && !flag_avx_m128_only) ? V4DFmode : V2DFmode;
>      case DImode:
>        return V2DImode;
>      case SImode:
> diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt
> index 85362d7..8968b25 100644
> --- a/gcc/config/i386/i386.opt
> +++ b/gcc/config/i386/i386.opt
> @@ -266,6 +266,10 @@ Target RejectNegative Var(flag_dispatch_scheduler)
>  Do dispatch scheduling if processor is bdver1 and Haifa scheduling
>  is selected.
>  
> +mavx-m128-only
> +Target Report Var(flag_avx_m128_only) Init(0)
> +Generate only 128-bit AVX instructions.

You've not actually disabled 256-bit avx insns.  The documentation for
that switch suggests that you should.  Perhaps you want to expand the
documentation to say use only 128-bit insns for auto-vectorization?


r~

Patch

From 35fc373edfeadb6db04d614360aaea1b71804b22 Mon Sep 17 00:00:00 2001
From: Changpeng Fang <chfang@houghton.(none)>
Date: Tue, 1 Mar 2011 12:50:46 -0800
Subject: [PATCH] Introduce flag -mavx-m128-only to generate only 128-bit avx instructions.

	* config/i386/i386.opt (mavx-m128-only): New flag.
	* config/i386/i386.c (ix86_preferred_simd_mode): Prefer 128-bit mode
	if the flag -mavx-m128-only is turned on.
---
 gcc/config/i386/i386.c   |    4 ++--
 gcc/config/i386/i386.opt |    4 ++++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index aa59ada..c0e3363 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -34747,9 +34747,9 @@  ix86_preferred_simd_mode (enum machine_mode mode)
   switch (mode)
     {
     case SFmode:
-      return TARGET_AVX ? V8SFmode : V4SFmode;
+      return (TARGET_AVX && !flag_avx_m128_only) ? V8SFmode : V4SFmode;
     case DFmode:
-      return TARGET_AVX ? V4DFmode : V2DFmode;
+      return (TARGET_AVX && !flag_avx_m128_only) ? V4DFmode : V2DFmode;
     case DImode:
       return V2DImode;
     case SImode:
diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt
index 85362d7..8968b25 100644
--- a/gcc/config/i386/i386.opt
+++ b/gcc/config/i386/i386.opt
@@ -266,6 +266,10 @@  Target RejectNegative Var(flag_dispatch_scheduler)
 Do dispatch scheduling if processor is bdver1 and Haifa scheduling
 is selected.
 
+mavx-m128-only
+Target Report Var(flag_avx_m128_only) Init(0)
+Generate only 128-bit AVX instructions.
+
 ;; ISA support
 
 m32
-- 
1.6.3.3