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

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

Comments

Fang, Changpeng - March 1, 2011, 8:59 p.m.
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
Jakub Jelinek - March 1, 2011, 9:07 p.m.
On Tue, Mar 01, 2011 at 02:59:03PM -0600, Fang, Changpeng wrote:
> 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;

Wouldn't
	return (TARGET_AVX && !flag_avx_m128_only) ? V8SFmode : VSFmode;
be more readable?

	Jakub
Fang, Changpeng - March 1, 2011, 9:47 p.m.
Yes, I can do that way.

Thanks,

Changpeng

Patch

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