[LLVMbugs] [Bug 2540] New: possible integer codegen error

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Thu Jul 10 11:25:08 PDT 2008


http://llvm.org/bugs/show_bug.cgi?id=2540

           Summary: possible integer codegen error
           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


This is for svn 53390 again, on Ubuntu Feisty on ia32.  Could easily be the
same bug as 2536 and/or 2539 but I figured I'd be safe and submit it.

[regehr at babel tmp3]$ llvm-gcc -O2 -fwrapv small.c -o small
[regehr at babel tmp3]$ ./small
0
[regehr at babel tmp3]$ llvm-gcc -O3 -fwrapv small.c -o small
[regehr at babel tmp3]$ ./small
1

[regehr at babel tmp3]$ cat small.c
#include <stdint.h>
#include <limits.h>
#include <stdio.h>

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 long int
mod_rhs(const long int rhs)
{
    if (rhs == 0) return 1;
    return rhs;
}


static inline int
lshift_s_u(int left, unsigned int right)
{
        if ((left < 0)
                || (right >= sizeof(int)*CHAR_BIT)
                || (left > (INT_MAX >> right))) {
                /* Avoid undefined behavior. */
                return left;
        }
        return left << right;
}


uint32_t g_37;
uint32_t g_73;
int16_t g_98 = 1;
uint32_t g_228;
int32_t g_246;
int8_t g_308;
int32_t func_1 (void);
int32_t func_116 (uint32_t p_117, uint32_t p_119, uint32_t p_120,
                  uint32_t p_121);
int32_t func_132 (int16_t p_133, uint32_t p_134, uint32_t p_135);
int32_t
func_1 (void)
{
  uint32_t l_311 = 0xA9D412B1L;
  int16_t l_316 = 1;
  for (g_73 = 1; g_73; --g_73)
    {
      int32_t l_310 = 0;
      uint32_t l_313 = 1;
      uint32_t l_318 = 1;
      for (g_73 = 0; g_73; g_73 += 1)
        {
        }
      if (g_98 +
          ((rshift_s_s (l_310, 1)) >=
           (((1 !=
              (1 & l_310)) % mod_rhs (l_311)) % mod_rhs (func_132 ((1 +
                                                                    g_246), 1,
                                                                   (1 <
                                                                    (1 |
                                                                     l_311) +
                                                                    (g_228
                                                                     &&
                                                                    
l_313)))))))
        {
          uint32_t l_314 = 1;
          func_116 ((1 <=
                     ((7L * l_314) %
                      mod_rhs (1 !=
                               (lshift_s_u (1, g_37)) * (l_316
                                                         || g_73)))), l_318,
                    g_308, 1);
        }
      else
        return 1;
    }
  return 1;
}

int32_t
func_116 (uint32_t p_117, uint32_t p_119, uint32_t p_120, uint32_t p_121)
{
  if (p_117)
    {
    }
  else
    for (g_98 = 0; g_98; ++g_98)
      {
      }
  return 1;
}

int32_t
func_132 (int16_t p_133, uint32_t p_134, uint32_t p_135)
{
  uint32_t l_138 = 0x1206B3A0L;
  return l_138;
}

int
main (void)
{
  func_1 ();
  printf ("%d\n", g_98);
  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