[LLVMbugs] [Bug 2791] New: possible induction variable bug
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Fri Sep 12 19:45:30 PDT 2008
http://llvm.org/bugs/show_bug.cgi?id=2791
Summary: possible induction variable bug
Product: new-bugs
Version: unspecified
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: new bugs
AssignedTo: unassignedbugs at nondot.org
ReportedBy: regehr at cs.utah.edu
CC: llvmbugs at cs.uiuc.edu
Seen using r56177 on Ubuntu Hardy on ia32.
The -O3 result is clearly wrong. Notice that g_5 is not assigned to anywhere
except in the header of the for loop.
llvm-gcc is valgrind-clean on the -O3 run.
regehr at john-home:~/volatile/tmp31$ llvm-gcc -O1 -w small.c -o small
regehr at john-home:~/volatile/tmp31$ ./small
2
regehr at john-home:~/volatile/tmp31$ llvm-gcc -O3 -w small.c -o small
regehr at john-home:~/volatile/tmp31$ ./small
1
regehr at john-home:~/volatile/tmp31$ cat small.c
#include <stdint.h>
#include <limits.h>
#include <stdio.h>
static inline unsigned long int
mod_rhs(const long int rhs)
{
if (rhs == 0) return 1;
return rhs;
}
static inline int
rshift_s_s(int left, int right)
{
if ((left < 0)
|| (right < 0)
|| (right >= sizeof(int)*CHAR_BIT)) {
/* Avoid implementation-defined and undefined behavior. */
return left;
}
return left >> right;
}
static inline unsigned int
lshift_u_u(unsigned int left, unsigned int right)
{
if ((right >= sizeof(unsigned int)*CHAR_BIT)
|| (left > (UINT_MAX >> right))) {
/* Avoid undefined behavior. */
return left;
}
return left << right;
}
static inline int
lshift_s_s(int left, int right)
{
if ((left < 0)
|| (right < 0)
|| (right >= sizeof(int)*CHAR_BIT)
|| (left > (INT_MAX >> right))) {
/* Avoid undefined behavior. */
return left;
}
return left << right;
}
uint32_t g_5;
uint32_t g_234;
uint32_t g_248;
volatile uint32_t g_283;
uint32_t g_286;
int32_t func_12 (uint32_t p_13, uint32_t p_14, uint32_t p_15);
int32_t
func_12 (uint32_t p_13, uint32_t p_14, uint32_t p_15)
{
return 1;
}
int32_t func_50 (uint32_t p_51, int8_t p_53);
int32_t func_50 (uint32_t p_51, int8_t p_53)
{
return 1;
}
int32_t func_55 (uint16_t p_57);
int32_t func_55 (uint16_t p_57)
{
if (1 % mod_rhs (1))
return 1;
return 1;
}
int32_t func_95 (int8_t p_96);
int32_t func_95 (int8_t p_96)
{
return 1;
}
int32_t func_103 (uint32_t p_105);
int32_t func_103 (uint32_t p_105)
{
return 1;
}
void func_8 (void);
void func_8 (void)
{
int32_t p_9 = 1;
uint32_t l_11 = 0;
uint32_t l_281;
if (g_5) return;
uint32_t l_280;
uint32_t l_282 = 1;
if (((rshift_s_s
(g_5
&& 1, func_12 (1 & (l_280 * g_234), func_50 ((1 | l_11), l_281),
(l_11 > (g_283 && p_9))))) + (lshift_u_u (g_5,
0)) ==
1) + (func_55 (func_103 (&l_282) & g_248 +
(lshift_s_s ((lshift_u_u (g_286, 1)), func_95 (p_9)))) >
((lshift_u_u (p_9, 1)) % mod_rhs (1))))
{
}
else
for (1; p_9; p_9--)
{
}
}
void func_1 (void);
void func_1 (void)
{
for (g_5 = 0; g_5 <= 1; g_5++) {
func_8 ();
}
}
int
main (void)
{
func_1 ();
printf ("%d\n", g_5);
return 0;
}
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list