This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH: Add --with-math=sse for x86
- From: "Richard Guenther" <richard dot guenther at gmail dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: gcc-patches at gcc dot gnu dot org, ubizjak at gmail dot com
- Date: Sun, 10 Aug 2008 20:07:12 +0200
- Subject: Re: PATCH: Add --with-math=sse for x86
- References: <20080809235249.GA10053@lucon.org> <20080810162707.GA4588@lucon.org>
On Sun, Aug 10, 2008 at 6:27 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Sat, Aug 09, 2008 at 04:52:49PM -0700, H.J. Lu wrote:
>> 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.
>>
>
> Here is the updated patch. It defines TARGET_SUBTARGET32_ISA_DEFAULT
> instead of TARGET_SUBTARGET_ISA_DEFAULT so that -march= can override
> it. Tested on Linux/x86-64. OK for trunk?
Why is this useful and why should this be made possible?
Richard.
> Thanks.
>
>
> H.J.
> ---
> 2008-08-10 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-10 07:22:54.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-10 07:22:54.000000000 -0700
> +++ gcc/config/i386/ssemath.h 2008-08-10 07:43:41.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_SUBTARGET32_ISA_DEFAULT
> +#define TARGET_SUBTARGET32_ISA_DEFAULT \
> + (OPTION_MASK_ISA_MMX | OPTION_MASK_ISA_SSE | OPTION_MASK_ISA_SSE2)
>