This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Hi, 

 Attached is the patch that introduces a new flag, -mavx-m128-only, for gcc to have the ability
to generate only 128-bit avx instructions. This flag (default is off) helps tuning avx performance
as well as benchmarking.  

The patch passed bootstrapping on x86_64-unknown-linux-gnu with "-O3 -g -march=bdver1 
-mavx-m128-only" and the necessary correctness and performance tests.

Is it OK to commit to 4.6 trunk?

Thanks,

Changpeng
 
From d84b2a81e0b1d5c2d01f75f1398440d21da26e29 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..f700b14 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 ? V4SFmode : V8SFmode) : V4SFmode;
     case DFmode:
-      return TARGET_AVX ? V4DFmode : V2DFmode;
+      return TARGET_AVX ? (flag_avx_m128_only ? V2DFmode : 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]