xcode - How can I enable UnAligned Access for ARM NEON in LLVM compiler? -
what flag enable unaligned memory access arm neon in llvm compiler. testing arm neon intrinsic program in xcode. accessing data unaligned memory:
char tempmemory[32] = {0}; char * ptempmem = tempmemory; ptempmem += 7; int32x2_t i32x2_value = vld1_lane_s32((int32_t const *) ptempmem, i32x2_offset, 0);
equivalent assembly intrinsic should vld1.32 {d0[0]}, [ptempmem]
, compiler align next multiple of 32 , access data. because of that, program not working fine.
so, how can enable unaligned access in llvm compiler?
this isn't neon problem, it's c problem, , issue is:
vld1_lane_s32((int32_t const *) ptempmem , i32x2_offset, 0);
casting pointer message compiler saying "hey, know looks bad, trust me, know i'm doing". converting pointer type a pointer type b, if pointer not have suitable alignment type b, gives undefined behaviour. therefore compiler free assume argument vld_1_lane_s32
32-bit aligned because there's no valid way couldn't (and you've promised know you're doing), emits instruction alignment hint.
now, could fiddle around options in attempt different kind of undefined behaviour matches want, that's bodging around problem rather fixing it. underlying neon instruction set can support unaligned accesses doesn't affect c language's definition of , restrictions around data alignment.
i'm not familiar how clever llvm is, i'm not sure if omitting pointer cast work (technically, c permits converting char *
other type of data pointer, should able sort out alignment itself). otherwise, solution use appropriate vld*_u8
operation load data vector via correct type, cast vreinterpret_s32_u8
once it's in register.
Comments
Post a Comment