LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 588 - Error in optimization: ( A || A ) << B
Summary: Error in optimization: ( A || A ) << B
Status: RESOLVED INVALID
Alias: None
Product: tools
Classification: Unclassified
Component: llvm-gcc (show other bugs)
Version: 1.5
Hardware: PC Linux
: P normal
Assignee: Unassigned LLVM Bugs
URL:
Keywords: invalid-bug
Depends on:
Blocks:
 
Reported: 2005-06-25 16:52 PDT by Bryan Turner
Modified: 2010-02-22 12:49 PST (History)
1 user (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bryan Turner 2005-06-25 16:52:35 PDT
Back from vacation.  Working through the group of optimizer errors.  This is the
reduced version.

Diff the output from this program when compiled in Optimized mode vs Debug mode.
 The assumption is that there should be no differences if the compiler optimized
correctly.

/*
// --- RANDOMLY GENERATED PROGRAM ---
// Program Generator by Bryan Turner (bryan.turner@pobox.com)
*/

#include <stdio.h>
unsigned long context = 0;
unsigned long DEPTH = 0;
void DumbHash( unsigned long value, unsigned int len )
{
  context += value;
  context ^= 0xA50F5AF0;
  printf( "%d\n", context );
}
/* --- GLOBAL VARIABLES --- */
unsigned short g_70300438 = 0xE7CA;


/* --- MAIN --- */
/* ------------------------------------------ */
int main(  )
{
  unsigned char l_94663863 = 0xF6;
  long l_03324849 = 0x9A7215CB;
  long l_99194556 = 0xE4255F06;
  if ( ( ( g_70300438 || g_70300438 )  << l_94663863 )  )
  {
        l_03324849 = l_99194556;
  }
  DumbHash( l_03324849, 4 );
}
Comment 1 Chris Lattner 2005-06-25 20:29:37 PDT
This is an invalid program.  Shifting by a value that is greater than the number
of bits in the operand is undefined in C.  In particular, this effectively performs:

   X << 0xF6

Since X is a long in this case (which is 32-bits), and 0xF6 > 31, this program
is not valid.

-Chris