This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH: PR target/39162: Gcc doesn't warn __m256 when -mavx isn't used
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: gcc-patches at gcc dot gnu dot org, ubizjak at gmail dot com
- Date: Thu, 12 Feb 2009 18:47:32 -0800
- Subject: Re: PATCH: PR target/39162: Gcc doesn't warn __m256 when -mavx isn't used
- References: <20090212215710.GA31753@lucon.org>
On Thu, Feb 12, 2009 at 01:57:10PM -0800, H.J. Lu wrote:
>
> When 256bit vector is used with AVX disabled, there is no ABI change
> warning. Since the middle-end can't handle 256bit vector without AVX,
> this patch just warns the ABI change without changing BLKmode to
> vector mode. OK for trunk?
>
Here is the updated patch. It warns ABI changes only if AVX isn't
enabled. OK for trunk if there are no regressions?
Thanks.
H.J.
---
gcc/
2009-02-12 H.J. Lu <hongjiu.lu@intel.com>
PR target/39162
* config/i386/i386.c (type_natural_mode): Add a new argument.
Return the original mode and warn ABI change if vector size
is 32byte.
(function_arg_advance): Updated.
(function_arg): Likewise.
(ix86_function_value): Likewise.
(ix86_return_in_memory): Likewise.
(ix86_sol10_return_in_memory): Likewise.
(ix86_gimplify_va_arg): Likewise.
(function_arg_32): Don't warn ABX ABI change here.
(function_arg_64): Likewise.
gcc/testsuite/
2009-02-12 H.J. Lu <hongjiu.lu@intel.com>
PR target/39162
* gcc.target/i386/pr39162.c: New.
Index: gcc/testsuite/gcc.target/i386/pr39162.c
===================================================================
--- gcc/testsuite/gcc.target/i386/pr39162.c (revision 0)
+++ gcc/testsuite/gcc.target/i386/pr39162.c (revision 0)
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -msse2" } */
+
+typedef long long __m256i __attribute__ ((__vector_size__ (32), __may_alias__));
+
+__m256i
+bar (__m256i x) /* { dg-warning "AVX" "" } */
+{
+ return x;
+}
Index: gcc/config/i386/i386.c
===================================================================
--- gcc/config/i386/i386.c (revision 144133)
+++ gcc/config/i386/i386.c (working copy)
@@ -4719,17 +4719,21 @@ init_cumulative_args (CUMULATIVE_ARGS *c
modes, the generic vector support in gcc will choose some non-vector mode
in order to implement the type. By computing the natural mode, we'll
select the proper ABI location for the operand and not depend on whatever
- the middle-end decides to do with these vector types. */
+ the middle-end decides to do with these vector types.
+
+ The midde-end can't deal with the vector types > 16 bytes. In this
+ case, we return the original mode and warn ABI change if CUM isn't
+ NULL. */
static enum machine_mode
-type_natural_mode (const_tree type)
+type_natural_mode (const_tree type, CUMULATIVE_ARGS *cum)
{
enum machine_mode mode = TYPE_MODE (type);
if (TREE_CODE (type) == VECTOR_TYPE && !VECTOR_MODE_P (mode))
{
HOST_WIDE_INT size = int_size_in_bytes (type);
- if ((size == 8 || size == 16)
+ if ((size == 8 || size == 16 || size == 32)
/* ??? Generic code allows us to create width 1 vectors. Ignore. */
&& TYPE_VECTOR_SUBPARTS (type) > 1)
{
@@ -4744,7 +4748,24 @@ type_natural_mode (const_tree type)
for (; mode != VOIDmode; mode = GET_MODE_WIDER_MODE (mode))
if (GET_MODE_NUNITS (mode) == TYPE_VECTOR_SUBPARTS (type)
&& GET_MODE_INNER (mode) == innermode)
- return mode;
+ {
+ if (size == 32 && !TARGET_AVX)
+ {
+ static bool warnedavx;
+
+ if (cum
+ && !warnedavx
+ && cum->warn_avx)
+ {
+ warnedavx = true;
+ warning (0, "AVX vector argument without AVX "
+ " enabled changes the ABI");
+ }
+ return TYPE_MODE (type);
+ }
+ else
+ return mode;
+ }
gcc_unreachable ();
}
@@ -5539,7 +5560,7 @@ function_arg_advance (CUMULATIVE_ARGS *c
words = (bytes + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
if (type)
- mode = type_natural_mode (type);
+ mode = type_natural_mode (type, NULL);
if (TARGET_64BIT && (cum ? cum->call_abi : DEFAULT_ABI) == MS_ABI)
function_arg_advance_ms_64 (cum, bytes, words);
@@ -5567,7 +5588,7 @@ function_arg_32 (CUMULATIVE_ARGS *cum, e
enum machine_mode orig_mode, tree type,
HOST_WIDE_INT bytes, HOST_WIDE_INT words)
{
- static bool warnedavx, warnedsse, warnedmmx;
+ static bool warnedsse, warnedmmx;
/* Avoid the AL settings for the Unix64 ABI. */
if (mode == VOIDmode)
@@ -5647,12 +5668,6 @@ function_arg_32 (CUMULATIVE_ARGS *cum, e
case V4DImode:
if (!type || !AGGREGATE_TYPE_P (type))
{
- if (!TARGET_AVX && !warnedavx && cum->warn_avx)
- {
- warnedavx = true;
- warning (0, "AVX vector argument without AVX enabled "
- "changes the ABI");
- }
if (cum->sse_nregs)
return gen_reg_or_parallel (mode, orig_mode,
cum->sse_regno + FIRST_SSE_REG);
@@ -5686,8 +5701,6 @@ static rtx
function_arg_64 (CUMULATIVE_ARGS *cum, enum machine_mode mode,
enum machine_mode orig_mode, tree type, int named)
{
- static bool warnedavx;
-
/* Handle a hidden AL argument containing number of registers
for varargs x86-64 functions. */
if (mode == VOIDmode)
@@ -5713,15 +5726,6 @@ function_arg_64 (CUMULATIVE_ARGS *cum, e
case V4DImode:
/* In 64bit, we pass TImode in interger registers and OImode on
stack. */
- if (!type || !AGGREGATE_TYPE_P (type))
- {
- if (!TARGET_AVX && !warnedavx && cum->warn_avx)
- {
- warnedavx = true;
- warning (0, "AVX vector argument without AVX enabled "
- "changes the ABI");
- }
- }
/* Unnamed 256bit vector mode parameters are passed on stack. */
if (!named)
@@ -5799,7 +5803,7 @@ function_arg (CUMULATIVE_ARGS *cum, enum
/* To simplify the code below, represent vector types with a vector mode
even if MMX/SSE are not active. */
if (type && TREE_CODE (type) == VECTOR_TYPE)
- mode = type_natural_mode (type);
+ mode = type_natural_mode (type, cum);
if (TARGET_64BIT && (cum ? cum->call_abi : DEFAULT_ABI) == MS_ABI)
return function_arg_ms_64 (cum, mode, omode, named, bytes);
@@ -6115,7 +6119,7 @@ ix86_function_value (const_tree valtype,
enum machine_mode mode, orig_mode;
orig_mode = TYPE_MODE (valtype);
- mode = type_natural_mode (valtype);
+ mode = type_natural_mode (valtype, NULL);
return ix86_function_value_1 (valtype, fntype_or_decl, orig_mode, mode);
}
@@ -6191,14 +6195,14 @@ ix86_return_in_memory (const_tree type,
#ifdef SUBTARGET_RETURN_IN_MEMORY
return SUBTARGET_RETURN_IN_MEMORY (type, fntype);
#else
- const enum machine_mode mode = type_natural_mode (type);
+ const enum machine_mode mode = type_natural_mode (type, NULL);
if (TARGET_64BIT_MS_ABI)
- return return_in_memory_ms_64 (type, mode);
- else if (TARGET_64BIT)
- return return_in_memory_64 (type, mode);
- else
- return return_in_memory_32 (type, mode);
+ return return_in_memory_ms_64 (type, mode);
+ else if (TARGET_64BIT)
+ return return_in_memory_64 (type, mode);
+ else
+ return return_in_memory_32 (type, mode);
#endif
}
@@ -6211,7 +6215,7 @@ bool
ix86_sol10_return_in_memory (const_tree type, const_tree fntype ATTRIBUTE_UNUSED)
{
int size;
- enum machine_mode mode = type_natural_mode (type);
+ enum machine_mode mode = type_natural_mode (type, NULL);
if (TARGET_64BIT)
return return_in_memory_64 (type, mode);
@@ -6665,7 +6669,7 @@ ix86_gimplify_va_arg (tree valist, tree
size = int_size_in_bytes (type);
rsize = (size + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
- nat_mode = type_natural_mode (type);
+ nat_mode = type_natural_mode (type, NULL);
switch (nat_mode)
{
case V8SFmode: