Bug 27151 - [4.1/4.2 Regression] ICE with -ftree-vectorize with mixed types
Summary: [4.1/4.2 Regression] ICE with -ftree-vectorize with mixed types
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.2.0
: P2 normal
Target Milestone: 4.1.1
Assignee: Richard Biener
URL:
Keywords: ice-on-valid-code
: 27154 (view as bug list)
Depends on: 27460
Blocks:
  Show dependency treegraph
 
Reported: 2006-04-13 23:03 UTC by Mark Loeser
Modified: 2006-05-06 17:42 UTC (History)
3 users (show)

See Also:
Host:
Target: x86_64-linux-gnu
Build:
Known to work: 4.0.3
Known to fail: 4.1.0 4.2.0
Last reconfirmed: 2006-04-27 10:16:44


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Loeser 2006-04-13 23:03:27 UTC
The following testcase fails on 4.1.0 and 4.2.0 when compiled with:

gcc -O2 -march=athlon64 -ftree-vectorize -c test.c
test.c: In function ‘vis_clear_data’:
test.c:9: error: unrecognizable insn:
(insn 28 27 29 5 (set (reg:V4SF 73)
        (vec_duplicate:V4SF (reg/v:SI 71 [ vis_type ]))) -1 (nil)
    (nil))
test.c:9: internal compiler error: in extract_insn, at recog.c:2037


float vs_data[75];
void vis_clear_data ()
{
  int vis_type, i;
  for (i = 0; i < 75; i++)
    {
      vs_data[i] = (vis_type == 1);
    }
}
Comment 1 Andrew Pinski 2006-04-14 00:28:11 UTC
What the vectorizer does looks good:
MEM[symbol: vs_data, base: (vector float *) ivtmp.54 * 16B] =  VEC_COND_EXPR < vect_cst_.35 != { 1, 1, 1, 1 } , { 0.0, 0.0, 0.0, 0.0 } , { 1.0e+0, 1.0e+0, 1.0e+0, 1.0e+0 } > ;
Comment 2 Andrew Pinski 2006-04-14 00:51:31 UTC
I get:
t.c:7: internal compiler error: in immed_double_const, at emit-rtl.c:464

Anyways this is either a middle-end issue while expanding the VEC_COND_EXPR or a target one while expanding it.
Comment 3 Andrew Pinski 2006-04-14 00:56:27 UTC
Confirmed, it also ICEs on powerpc-linux-gnu with -maltivec -O1 -ftree-vectorize so it is a middle-end issue.
Comment 4 Andrew Pinski 2006-04-14 01:01:38 UTC
Actually I take that back about being a middle-end issue and not a vectorizer one.
  vector float vect_cst_.35;
  int vis_type;
....
  vect_cst_.35 = {vis_type, vis_type, vis_type, vis_type};


so it is getting the wrong type for the vector.
Comment 5 Andrew Pinski 2006-04-15 16:44:54 UTC
*** Bug 27154 has been marked as a duplicate of this bug. ***
Comment 6 Richard Biener 2006-04-27 10:16:44 UTC
The vectorizer doesn't seem to handle differing types for COND_EXPRs.  So something along

*** tree-vect-transform.c       (revision 113296)
--- tree-vect-transform.c       (working copy)
*************** vectorizable_condition (tree stmt, block
*** 2115,2120 ****
--- 2115,2125 ----
    then_clause = TREE_OPERAND (op, 1);
    else_clause = TREE_OPERAND (op, 2);
  
+   /* We do not handle two different vector types for the condition
+      and the values.  */
+   if (TREE_TYPE (TREE_OPERAND (cond_expr, 0)) != TREE_TYPE (vectype))
+     return false;
+ 
    if (!vect_is_simple_cond (cond_expr, loop_vinfo))
      return false;

should fix it.
Comment 7 patchapp@dberlin.org 2006-04-27 12:50:17 UTC
Subject: Bug number PR27151

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-04/msg01034.html
Comment 8 Richard Biener 2006-05-06 17:38:00 UTC
Subject: Bug 27151

Author: rguenth
Date: Sat May  6 17:37:53 2006
New Revision: 113580

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113580
Log:
2006-05-06   Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/27151
	* tree-vect-transform.c (vectorizable_condition): Punt on
	values that have a different type than the condition.

	* gcc.dg/vect/pr27151.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.dg/vect/pr27151.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-vect-transform.c

Comment 9 Richard Biener 2006-05-06 17:41:55 UTC
Subject: Bug 27151

Author: rguenth
Date: Sat May  6 17:41:48 2006
New Revision: 113581

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113581
Log:
2006-05-06   Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/27151
	* tree-vect-transform.c (vectorizable_condition): Punt on
	values that have a different type than the condition.

	* gcc.dg/vect/pr27151.c: New testcase.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/gcc.dg/vect/pr27151.c
      - copied unchanged from r113580, trunk/gcc/testsuite/gcc.dg/vect/pr27151.c
Modified:
    branches/gcc-4_1-branch/gcc/ChangeLog
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_1-branch/gcc/tree-vect-transform.c

Comment 10 Richard Biener 2006-05-06 17:42:00 UTC
Fixed.