[llvm-dev] How do I teach codegen to handle i8 arrays as i32s?

Matt Arsenault via llvm-dev llvm-dev at lists.llvm.org
Fri Jan 3 10:42:36 PST 2020


> On Jan 3, 2020, at 13:00, Gleb Popov via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> Hello.
> 
> My backend supports only i32 stores. Given the following IR:
> 
>   %2 = alloca [2 x i8], align 1
> 
>   %4 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
>   store i8 1, i8* %4, align 1
>   %5 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 1
>   store i8 2, i8* %5, align 1
> 
> is it possible to convince LLVM codegen to first load 4 bytes, then blend it with the value being stored using "or" and then store 4 bytes back?
> 

Yes, you can accomplish this with custom lowering for the store

-Matt



More information about the llvm-dev mailing list