-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Description
Bugzilla Link | 3740 |
Resolution | FIXED |
Resolved on | Jan 01, 2010 12:44 |
Version | unspecified |
OS | Linux |
Extended Description
This is seen using r66136 on x86 on Ubuntu Hardy.
The code below should compile into "return 0", but fails to. If the line of code in func_1() is pasted into main(), everything gets optimized properly.
regehr@john-home:~/volatile/tmp141$ cat small2.c
#include <stdint.h>
#include <limits.h>
#define safe_lshift_macro_int32_t_s_s(left,right)
(((((int32_t)(left)) < ((int32_t)0))
|| (((int)(right)) < ((int32_t)0))
|| (((int)(right)) >= sizeof(int32_t)*CHAR_BIT)
|| (((int32_t)(left)) > ((INT32_MAX) >> ((int)(right)))))
? ((int32_t)(left))
: (((int32_t)(left)) << ((int)(right))))
static int32_t
safe_lshift_func_int32_t_s_s(int32_t _left, int _right)
{
return safe_lshift_macro_int32_t_s_s(_left,_right);
}
static uint8_t g_6;
static void func_1 (void);
static void func_1 (void)
{
g_6 = safe_lshift_func_int32_t_s_s (g_6, g_6);
}
int main (void)
{
func_1 ();
return g_6;
}
regehr@john-home:~/volatile/tmp141$ llvm-gcc -O6 small2.c -S --emit-llvm -o -
; ModuleID = 'small2.c'
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32"
target triple = "i386-pc-linux-gnu"
@g_6 = internal global i8 0 ; <i8*> [#uses=2]
define i32 @main() nounwind {
entry:
%0 = load i8* @g_6, align 1 ; [#uses=2]
%1 = zext i8 %0 to i32 ; [#uses=5]
%2 = icmp ugt i8 %0, 31 ; [#uses=1]
br i1 %2, label %func_1.exit, label %bb6.i.i
bb6.i.i: ; preds = %entry
%3 = lshr i32 2147483647, %1 ; [#uses=1]
%4 = icmp slt i32 %3, %1 ; [#uses=1]
%5 = select i1 %4, i32 0, i32 %1 ; [#uses=1]
%..i = shl i32 %1, %5 ; [#uses=1]
br label %func_1.exit
func_1.exit: ; preds = %entry, %bb6.i.i
%6 = phi i32 [ %..i, %bb6.i.i ], [ %1, %entry ] ; [#uses=2]
%7 = trunc i32 %6 to i8 ; [#uses=1]
store i8 %7, i8* @g_6, align 1
%8 = and i32 %6, 255 ; [#uses=1]
ret i32 %8
}