weixuegong
2013-Sep-24 03:37 UTC
[LLVMdev] Question on bit layout of array after bitcasting in llvm
Hi, all I get some code: %0 = bitcast i16 %arg1 to <2 x i8> %2 = extractelement <2 x i8> %0, i32 1 %arg1 in mem : 0000000011111111 |---8bit---| |---8bit---| After bitcasting, %0 is an ptr to vector. So is %0 also the address of the first element of the vector? And what is %2 exactly? Is it the second element of vector(11111111) or, 00000000? I'll be very grateful if someone could give me some advice.
Tim Northover
2013-Sep-24 09:17 UTC
[LLVMdev] Question on bit layout of array after bitcasting in llvm
Hi,> %0 = bitcast i16 %arg1 to <2 x i8> > %2 = extractelement <2 x i8> %0, i32 1 > > %arg1 in mem : > 0000000011111111 > |---8bit---| |---8bit---| > > After bitcasting, %0 is an ptr to vector.This isn't quite right. %0 is a real vector, not a pointer to one. If you have hardware support for <2 x i8> then both elements would probably be living in a single register ready for SIMD operations to be performed on them. It should be identical to if you'd stored %arg1 to some address as i16 and reloaded it as <2 x i8>.> And what is %2 exactly? Is it the second element of vector(11111111) or, > 00000000?Being slightly obtuse: yes. The extractelement would normally be a register-move rather than any kind of load (unless %0 had been spilled due to pressure) and result in an i8 having one of those two values. Exactly which of those it is depends slightly on whether your target is big-endian or little-endian and exactly how it handles the endianness of vectors. On a little-endian machine it would almost always be 00000000 I think. Cheers. Tim.
Seemingly Similar Threads
- [LLVMdev] loop vectorizer: Unexpected extract/insertelement
- [LLVMdev] loop vectorizer: Unexpected extract/insertelement
- [LLVMdev] loop vectorizer: Unexpected extract/insertelement
- Question about 'DAGTypeLegalizer::SplitVecOp_EXTRACT_VECTOR_ELT'
- Question about 'DAGTypeLegalizer::SplitVecOp_EXTRACT_VECTOR_ELT'