Skip to content

Error in optimization: ( A || A ) << B #960

Closed
@llvmbot

Description

@llvmbot
Bugzilla Link 588
Resolution INVALID
Resolved on Feb 22, 2010 12:49
Version 1.5
OS Linux
Reporter LLVM Bugzilla Contributor

Extended Description

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 );
}

Activity

lattner

lattner commented on Jun 26, 2005

@lattner
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillainvalidResolved as invalid, i.e. not a bugllvm-toolsAll llvm tools that do not have corresponding tag

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @Quuxplusone@lattner@llvmbot

        Issue actions

          Error in optimization: ( A || A ) << B · Issue #960 · llvm/llvm-project