URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Only display areas with differences |
Details |
Blame |
View Log
Rev 298 |
Rev 338 |
/* PR tree-optimization/34244 */
|
/* PR tree-optimization/34244 */
|
/* { dg-do run } */
|
/* { dg-do run } */
|
/* { dg-options "-O2 " } */
|
/* { dg-options "-O2 " } */
|
|
|
int __attribute__((noinline)) GetParent(void)
|
int __attribute__((noinline)) GetParent(void)
|
{
|
{
|
static int count = 0;
|
static int count = 0;
|
count++;
|
count++;
|
switch (count)
|
switch (count)
|
{
|
{
|
case 1:
|
case 1:
|
case 3:
|
case 3:
|
case 4:
|
case 4:
|
return 1;
|
return 1;
|
default:
|
default:
|
return 0;
|
return 0;
|
}
|
}
|
}
|
}
|
int __attribute__((noinline)) FindCommonAncestor(int aNode1, int aNode2)
|
int __attribute__((noinline)) FindCommonAncestor(int aNode1, int aNode2)
|
{
|
{
|
if (aNode1 && aNode2) {
|
if (aNode1 && aNode2) {
|
int offset = 0;
|
int offset = 0;
|
int anc1 = aNode1;
|
int anc1 = aNode1;
|
for (;;) {
|
for (;;) {
|
++offset;
|
++offset;
|
int parent = GetParent();
|
int parent = GetParent();
|
if (!parent)
|
if (!parent)
|
break;
|
break;
|
anc1 = parent;
|
anc1 = parent;
|
}
|
}
|
int anc2 = aNode2;
|
int anc2 = aNode2;
|
for (;;) {
|
for (;;) {
|
--offset;
|
--offset;
|
int parent = GetParent();
|
int parent = GetParent();
|
if (!parent)
|
if (!parent)
|
break;
|
break;
|
anc2 = parent;
|
anc2 = parent;
|
}
|
}
|
if (anc1 == anc2) {
|
if (anc1 == anc2) {
|
anc1 = aNode1;
|
anc1 = aNode1;
|
anc2 = aNode2;
|
anc2 = aNode2;
|
while (offset > 0) {
|
while (offset > 0) {
|
anc1 = GetParent();
|
anc1 = GetParent();
|
--offset;
|
--offset;
|
}
|
}
|
while (offset < 0) {
|
while (offset < 0) {
|
anc2 = GetParent();
|
anc2 = GetParent();
|
++offset;
|
++offset;
|
}
|
}
|
while (anc1 != anc2) {
|
while (anc1 != anc2) {
|
anc1 = GetParent();
|
anc1 = GetParent();
|
anc2 = GetParent();
|
anc2 = GetParent();
|
}
|
}
|
return anc1;
|
return anc1;
|
}
|
}
|
}
|
}
|
return 0;
|
return 0;
|
}
|
}
|
extern void abort (void);
|
extern void abort (void);
|
int main()
|
int main()
|
{
|
{
|
if (FindCommonAncestor (1, 1) != 0)
|
if (FindCommonAncestor (1, 1) != 0)
|
abort ();
|
abort ();
|
return 0;
|
return 0;
|
}
|
}
|
|
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.