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

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

Comments

Fang, Changpeng - March 3, 2011, 5:59 p.m.
Yes, you are right. I renamed the flag to -mprefers-avx128 and modified
the documentation.

Is this OK to commit to 4.6?

Thanks,

Changpeng
Richard Henderson - March 4, 2011, 7:31 a.m.
On 03/04/2011 03:59 AM, Fang, Changpeng wrote:
> +mprefers-avx128
> +Target Report Var(flag_prefers_avx128) Init(0)

Use "mprefer-avx128".  A switch should use a verb in command form -- you're 
telling the compiler what to do.  Change both the switch and the flag spelling.


> +Auto-vectorizer prefers to generate 128-bit AVX instructions instead of 256-bit
> +ones.

"Use 128-bit AVX instructions instead of 256-bit AVX instructions in the auto-vectorizer".

Ok with those changes.


r~

Patch

From 8c3ddf13024d426954986befd742448fa3805788 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 -mprefers-avx128 for the vectorizer to generate only 128-bit avx insns.

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

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index aa59ada..b92c10d 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_prefers_avx128) ? V8SFmode : V4SFmode;
     case DFmode:
-      return TARGET_AVX ? V4DFmode : V2DFmode;
+      return (TARGET_AVX && !flag_prefers_avx128) ? V4DFmode : V2DFmode;
     case DImode:
       return V2DImode;
     case SImode:
diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt
index 85362d7..b4979ee 100644
--- a/gcc/config/i386/i386.opt
+++ b/gcc/config/i386/i386.opt
@@ -266,6 +266,11 @@  Target RejectNegative Var(flag_dispatch_scheduler)
 Do dispatch scheduling if processor is bdver1 and Haifa scheduling
 is selected.
 
+mprefers-avx128
+Target Report Var(flag_prefers_avx128) Init(0)
+Auto-vectorizer prefers to generate 128-bit AVX instructions instead of 256-bit
+ones.
+
 ;; ISA support
 
 m32
-- 
1.6.3.3