Bug 19096 - Wrong code with -ftree-vectorize
Summary: Wrong code with -ftree-vectorize
Status: RESOLVED DUPLICATE of bug 19067
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: unknown
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2004-12-21 01:11 UTC by Serge Belyshev
Modified: 2005-07-23 22:49 UTC (History)
3 users (show)

See Also:
Host:
Target: i386-pc-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Serge Belyshev 2004-12-21 01:11:48 UTC
use "-O1 -ftree-vectorize" to reproduce:
------------------------------------------------------------------------------
extern void abort (void);

static unsigned int prime_tab[] = {7, 127};

int main (void)
{
  unsigned int n, low, mid, high;

  n = 64;
  low = 0;
  high = 1;
  while (low != high)
    {
      mid = low + (high - low) / 2;
      if (n > prime_tab[mid])
	low = mid + 1;
      else
	high = mid;
    }
  
  if (n > prime_tab[low])
    abort ();
  return low;
}
------------------------------------------------------------------------------
Comment 1 Andrew Pinski 2004-12-21 01:28:24 UTC
This works for me on ppc-darwin.
In .vect, I get "number of iterations cannot be computed".
Comment 2 Wolfgang Bangerth 2004-12-21 02:40:59 UTC
This works for me, too, with a snapshot from 2004-12-14, or at least it 
doesn't abort and returns a return code of 1. What do you see, and what 
flags exactly do you use? I tried with 
  -march=pentium4 -mmmx -msse -msse2 -mfpmath=sse -O1 -ftree-vectorize x.c 
 
W. 
Comment 3 Serge Belyshev 2004-12-21 08:30:20 UTC
My bad, I used wrong tree... The problem is in these patches:
http://gcc.gnu.org/ml/gcc-patches/2004-12/msg01381.html and not in mainline.
Comment 4 Zdenek Dvorak 2004-12-21 08:36:09 UTC
Which one of them?  And what is the problem?
Comment 5 Serge Belyshev 2004-12-21 09:28:02 UTC
The problem is with this patch

	* tree-optimize.c (init_tree_optimization_passes): Add
	dominator and dce pass after pre.

and it is fixed by http://gcc.gnu.org/ml/gcc-patches/2004-12/msg00514.html , so
this is a dup of bug 19067

*** This bug has been marked as a duplicate of 19067 ***