[cfe-dev] GEP index type

Rotem, Nadav nadav.rotem at intel.com
Sat Dec 10 09:20:55 PST 2011


Hi, 

I have a question regarding the LLVM-IR which is generated by clang. When I compile the code below on a 64-bit system, clang generates a GEP instruction with a 64 bit index. 

int demo(int *A, short i) { return A[i]; }

becomes:

%4 = sext i16 %3 to i64
%6 = getelementptr inbounds i32* %5, i64 %4

I would expect to see an i16 index, since the index is known to be within the 0..16 bit range. Why does clang widen the index to a 64bit value ?

Thanks,
Nadav
---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.





More information about the cfe-dev mailing list