On Wed, Mar 16, 2011 at 11:38 AM, H.J. Lu <hjl.to...@gmail.com> wrote:
> On Sun, Feb 27, 2011 at 5:45 AM, Uros Bizjak <ubiz...@gmail.com> wrote:
>> Hello!
>>
>> Attached [RFC] patch vectorizes calls to floor, ceil, trunc and rint
>> (and their float variants) functions using roundps/roundpd SSE4.1
>> instruction.
>>
>> 2011-02-27  Uros Bizjak  <ubiz...@gmail.com>
>>
>>        * config/i386/i386.md (ROUND_FLOOR): New constant.
>>        (ROUND_CEIL): Ditto.
>>        (ROUND_TRUNC): Ditto.
>>        (ROUND_MXCSR): Ditto.
>>        (ROUND_NO_EXC): Ditto.
>>        (rint<mode>2): Use new defines instead of numerical constant.
>>        (floor<mode>2): Ditto.
>>        (ceil<mode>2): Ditto.
>>        (btrunc<mode>2): Ditto.
>>        * config/i386/i386-builtin-types.def: Define ROUND function type
>>        aliases.
>>        * config/i386/i386.c (enum ix86_builtins): Add
>>        IX86_BUILTIN_{FLOOR,CEIL,TRUNC,RINT}{PS,PD}{,256} defines.
>>        (struct builtin_description): Add
>>        __builtin_ia32_{floor,ceil,trunc,rint}{pd,ps}{,256} descriptions.
>>        (ix86_expand_sse_round): New static function.
>>        (ix86_expand_args_builtin): Call ix86_expand_sse_round for ROUND
>>        function types.
>>        (ix86_builtin_vectorized_function): Handle
>>        BUILT_IN_{FLOOR,CEIL,TRUNC,RINT}{,F} builtins.
>>
>> Patch was bootstrapped and regression tested on x86_64-pc-linux-gnu
>> (--with-fpmath=avx). Currently, it does not include test cases, but it
>> is RFC at this gcc development stage anyway.
>
> This caused:
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48154
>
> We need to check TARGET_ROUND before using __builtin_ia32_truncps.

This patch fixes the compilation. OK for trunk?

Thanks.


-- 
H.J.
---
2011-03-16  H.J. Lu  <hongjiu...@intel.com>

        PR target/48154
        * config/i386/i386.c (ix86_builtin_vectorized_function): Check
        TARGET_ROUND for BUILT_IN_{FLOOR,CEIL,TRUNC,RINT}{,F} builtins.
2011-03-16  H.J. Lu  <hongjiu...@intel.com>

        PR target/48154
        * config/i386/i386.c (ix86_builtin_vectorized_function): Check
        TARGET_ROUND for BUILT_IN_{FLOOR,CEIL,TRUNC,RINT}{,F} builtins.

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index ca3b339..b2aa74d 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -27883,7 +27883,7 @@ ix86_builtin_vectorized_function (tree fndecl, tree 
type_out,
 
     case BUILT_IN_FLOOR:
       /* The round insn does not trap on denormals.  */
-      if (flag_trapping_math)
+      if (flag_trapping_math || !TARGET_ROUND)
        break;
 
       if (out_mode == DFmode && in_mode == DFmode)
@@ -27897,7 +27897,7 @@ ix86_builtin_vectorized_function (tree fndecl, tree 
type_out,
 
     case BUILT_IN_FLOORF:
       /* The round insn does not trap on denormals.  */
-      if (flag_trapping_math)
+      if (flag_trapping_math || !TARGET_ROUND)
        break;
 
       if (out_mode == SFmode && in_mode == SFmode)
@@ -27911,7 +27911,7 @@ ix86_builtin_vectorized_function (tree fndecl, tree 
type_out,
 
     case BUILT_IN_CEIL:
       /* The round insn does not trap on denormals.  */
-      if (flag_trapping_math)
+      if (flag_trapping_math || !TARGET_ROUND)
        break;
 
       if (out_mode == DFmode && in_mode == DFmode)
@@ -27925,7 +27925,7 @@ ix86_builtin_vectorized_function (tree fndecl, tree 
type_out,
 
     case BUILT_IN_CEILF:
       /* The round insn does not trap on denormals.  */
-      if (flag_trapping_math)
+      if (flag_trapping_math || !TARGET_ROUND)
        break;
 
       if (out_mode == SFmode && in_mode == SFmode)
@@ -27939,7 +27939,7 @@ ix86_builtin_vectorized_function (tree fndecl, tree 
type_out,
 
     case BUILT_IN_TRUNC:
       /* The round insn does not trap on denormals.  */
-      if (flag_trapping_math)
+      if (flag_trapping_math || !TARGET_ROUND)
        break;
 
       if (out_mode == DFmode && in_mode == DFmode)
@@ -27953,7 +27953,7 @@ ix86_builtin_vectorized_function (tree fndecl, tree 
type_out,
 
     case BUILT_IN_TRUNCF:
       /* The round insn does not trap on denormals.  */
-      if (flag_trapping_math)
+      if (flag_trapping_math || !TARGET_ROUND)
        break;
 
       if (out_mode == SFmode && in_mode == SFmode)
@@ -27967,7 +27967,7 @@ ix86_builtin_vectorized_function (tree fndecl, tree 
type_out,
 
     case BUILT_IN_RINT:
       /* The round insn does not trap on denormals.  */
-      if (flag_trapping_math)
+      if (flag_trapping_math || !TARGET_ROUND)
        break;
 
       if (out_mode == DFmode && in_mode == DFmode)
@@ -27981,7 +27981,7 @@ ix86_builtin_vectorized_function (tree fndecl, tree 
type_out,
 
     case BUILT_IN_RINTF:
       /* The round insn does not trap on denormals.  */
-      if (flag_trapping_math)
+      if (flag_trapping_math || !TARGET_ROUND)
        break;
 
       if (out_mode == SFmode && in_mode == SFmode)

Reply via email to