Okay. Then Sema should insert an ImplicitCastExpr, just like it does for x1 and x2.

On Nov 13, 2008, at 8:24 PM, Zhongxing Xu wrote:


I'm not certain. Note that the 'long long' value 'k' was not truncated. Is this a Sema bug, or is this the correct behavior? For this target LongLongWidth is 64, the bit width for 'int' is 32, and the bit width for a pointer is (I believe) 32 bits as well.

It's truncated in the generated code:

void f() {
  int a[10];
  short x1;
  unsigned short x2;
  long x5;
  unsigned long x6;
  long long x3;
  unsigned long long x4;

  a[x1] = 3;
  a[x2] = 3;
  a[x3] = 3;
  a[x4] = 3;
  a[x5] = 3;
  a[x6] = 3;
}

; ModuleID = 'array3.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 = "i686-pc-linux-gnu"

define void @f(...) nounwind {
entry:
    %a = alloca [10 x i32], align 4        ; <[10 x i32]*> [#uses=6]
    %x1 = alloca i16, align 2        ; <i16*> [#uses=1]
    %x2 = alloca i16, align 2        ; <i16*> [#uses=1]
    %x5 = alloca i32, align 4        ; <i32*> [#uses=1]
    %x6 = alloca i32, align 4        ; <i32*> [#uses=1]
    %x3 = alloca i64, align 4        ; <i64*> [#uses=1]
    %x4 = alloca i64, align 4        ; <i64*> [#uses=1]
    %tmp = load i16* %x1        ; <i16> [#uses=1]
%arraydecay = getelementptr [10 x i32]* %a, i32 0, i32 0 ; <i32*> [#uses=1]
    %idxprom = sext i16 %tmp to i32        ; <i32> [#uses=1]
%arrayidx = getelementptr i32* %arraydecay, i32 %idxprom ; <i32*> [#uses=1]
    store i32 3, i32* %arrayidx
    %tmp1 = load i16* %x2        ; <i16> [#uses=1]
%arraydecay2 = getelementptr [10 x i32]* %a, i32 0, i32 0 ; <i32*> [#uses=1]
    %idxprom3 = zext i16 %tmp1 to i32        ; <i32> [#uses=1]
%arrayidx4 = getelementptr i32* %arraydecay2, i32 %idxprom3 ; <i32*> [#uses=1]
    store i32 3, i32* %arrayidx4
    %tmp5 = load i64* %x3        ; <i64> [#uses=1]
%arraydecay6 = getelementptr [10 x i32]* %a, i32 0, i32 0 ; <i32*> [#uses=1]
    %idxprom7 = trunc i64 %tmp5 to i32        ; <i32> [#uses=1]
%arrayidx8 = getelementptr i32* %arraydecay6, i32 %idxprom7 ; <i32*> [#uses=1]
    store i32 3, i32* %arrayidx8
    %tmp9 = load i64* %x4        ; <i64> [#uses=1]
%arraydecay10 = getelementptr [10 x i32]* %a, i32 0, i32 0 ; <i32*> [#uses=1]
    %idxprom11 = trunc i64 %tmp9 to i32        ; <i32> [#uses=1]
%arrayidx12 = getelementptr i32* %arraydecay10, i32 %idxprom11 ; <i32*> [#uses=1]
    store i32 3, i32* %arrayidx12
    %tmp13 = load i32* %x5        ; <i32> [#uses=1]
%arraydecay14 = getelementptr [10 x i32]* %a, i32 0, i32 0 ; <i32*> [#uses=1] %arrayidx15 = getelementptr i32* %arraydecay14, i32 %tmp13 ; <i32*> [#uses=1]
    store i32 3, i32* %arrayidx15
    %tmp16 = load i32* %x6        ; <i32> [#uses=1]
%arraydecay17 = getelementptr [10 x i32]* %a, i32 0, i32 0 ; <i32*> [#uses=1] %arrayidx18 = getelementptr i32* %arraydecay17, i32 %tmp16 ; <i32*> [#uses=1]
    store i32 3, i32* %arrayidx18
    br label %return

return:        ; preds = %entry
    ret void
}

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to