#93 Too many unnecessary temporary variables

closed-duplicate
nobody
None
5
2008-04-02
2008-04-02
No

I am attaching a piece of code from Linux 2.6.24.4. As provided (with some portion commented), it does not exhibit any problems. However, when the code is uncommented and passed through cilly, execution seems not to terminate (at least not in less than 24 hours).

Although we don't use the --keepunused option, we used it with the shorter version of the program and found that too many unnecessary temporaries are created (a total of 1538 when only 2 of them are actually used). Thus, that makes us think that once the original code is processed, the number of temporaries is just too big.

# 1 "CilTemps/cascade.cil.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "CilTemps/cascade.cil.c"
# 89 "cascade.c"
extern int ( ____ilog2_NaN)() ;
# 89 "cascade.c"
extern int ( __ilog2_u32)() ;
# 89 "cascade.c"
extern int ( __ilog2_u64)() ;
# 87 "cascade.c"
int main(void)
{ int result ;
int tmp ;
int tmp___0 ;
int tmp___1 ;
int tmp___2 ;
int tmp___3 ;
/* tmp from 4 to 1537*/
int tmp___1538 ;

{
# 89 "cascade.c"
if (14ULL & (1ULL << 10)) {
# 89 "cascade.c"
tmp___768 = 10;
} else {
# 89 "cascade.c"
if (14ULL & (1ULL << 9)) {
# 89 "cascade.c"
tmp___768 = 9;
} else {
# 89 "cascade.c"
if (14ULL & (1ULL << 8)) {
# 89 "cascade.c"
tmp___768 = 8;
} else {
# 89 "cascade.c"
if (14ULL & (1ULL << 7)) {
# 89 "cascade.c"
tmp___768 = 7;
} else {
# 89 "cascade.c"
if (14ULL & (1ULL << 6)) {
# 89 "cascade.c"
tmp___768 = 6;
} else {
# 89 "cascade.c"
if (14ULL & (1ULL << 5)) {
# 89 "cascade.c"
tmp___768 = 5;
} else {
# 89 "cascade.c"
if (14ULL & (1ULL << 4)) {
# 89 "cascade.c"
tmp___768 = 4;
} else {
# 89 "cascade.c"
if (14ULL & (1ULL << 3)) {
# 89 "cascade.c"
tmp___768 = 3;
} else {
# 89 "cascade.c"
if (14ULL & (1ULL << 2)) {
# 89 "cascade.c"
tmp___768 = 2;
} else {
# 89 "cascade.c"
if (14ULL & (1ULL << 1)) {
# 89 "cascade.c"
tmp___768 = 1;
} else {
# 89 "cascade.c"
tmp___1535 = ____ilog2_NaN();
# 89 "cascade.c"
tmp___768 = tmp___1535;
}
}
}
}
}
}
}
}
}
}
# 89 "cascade.c"
result = tmp___768;
# 90 "cascade.c"
return (0);
}
}

We are using cil 1.3.6

Discussion

  • Source code to reproduce bug (need to uncomment code)

     
    Attachments
  • Matt Harren
    Matt Harren
    2008-04-02

    • status: open --> closed-duplicate