PATCH: Add --with-math=sse for x86

H.J. Lu hjl.tools@gmail.com
Sun Aug 10 04:52:00 GMT 2008


This patch adds an option to configure gcc with SSE math by default.
Tested on Linux/x86-64.  OK for trunk?

Thanks.


H.J.
---
2008-08-09  H.J. Lu  <hongjiu.lu@intel.com>

	* config.gcc: Support --with-math=sse for x86.

	* config/i386/ssemath.h: New.

--- gcc/config.gcc.ssemath	2008-08-09 14:19:38.000000000 -0700
+++ gcc/config.gcc	2008-08-09 16:51:38.000000000 -0700
@@ -2544,6 +2544,27 @@ if test x$with_cpu = x ; then
   esac
 fi
 
+# Support --with-math.
+if test x$with_math != x; then
+  case ${target} in
+    i[34567]86-*-* | x86_64-*-*)
+      case ${with_math} in
+      sse)
+	tm_file="${tm_file} i386/ssemath.h"
+	;;
+      *)
+	echo "Invalid --with-math=$with_math" 1>&2
+	exit 1
+	;;
+      esac
+      ;;
+    *)
+      echo "--with-math isn't supported for $target." 1>&2
+      exit 1
+      ;;
+  esac
+fi
+
 # Similarly for --with-schedule.
 if test x$with_schedule = x; then
 	case ${target} in
--- gcc/config/i386/ssemath.h.ssemath	2008-08-09 14:37:03.000000000 -0700
+++ gcc/config/i386/ssemath.h	2008-08-09 14:51:38.000000000 -0700
@@ -0,0 +1,25 @@
+/* Copyright (C) 2008
+   Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+#undef TARGET_FPMATH_DEFAULT
+#define TARGET_FPMATH_DEFAULT (TARGET_SSE2 ? FPMATH_SSE : FPMATH_387)
+
+#undef TARGET_SUBTARGET_ISA_DEFAULT
+#define TARGET_SUBTARGET_ISA_DEFAULT \
+   (OPTION_MASK_ISA_MMX | OPTION_MASK_ISA_SSE | OPTION_MASK_ISA_SSE2)



More information about the Gcc-patches mailing list