OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [opt/] [strength-reduce.C] - Blame information for rev 774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 693 jeremybenn
// This testcase was miscompiled on s390x, because strength-reduction
2
// did not see biv in C::foo as used after loop, but it was used
3
// in a REG_EQUAL note.
4
// { dg-do run }
5
// { dg-options "-O2" }
6
 
7
extern "C" void abort (void);
8
 
9
struct C
10
{
11
  int foo (char ch, int offset = __INT_MAX__) const;
12
  int bar (int offset, char c) const;
13
   const char *a;
14
};
15
 
16
int C::bar (int offset, char c) const
17
{
18
  char ch = a[offset];
19
  if (ch < c)
20
    return -1;
21
  if (ch > c)
22
    return 1;
23
  return 0;
24
}
25
 
26
int C::foo (char ch, int offset) const
27
{
28
  int len = __builtin_strlen (a);
29
  if (len == 0)
30
    return __INT_MAX__;
31
  if (offset >= len)
32
    offset = len - 1;
33
 
34
  while (bar (offset, ch) != 0)
35
    {
36
      if (offset == 0)
37
        return __INT_MAX__;
38
      offset--;
39
    }
40
 
41
  return offset;
42
}
43
 
44
int main (void)
45
{
46
  C c;
47
  c.a = "/some/dir/file.ext";
48
  if (c.foo ('/') != 9)
49
    abort ();
50
  return 0;
51
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.