You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The LLVM IR generated for cir.complex.create is a bit ugly since it includes the insertvalue instruction, which typically is not generated in upstream CodeGen.
-- Originally posted in the comments of #723 .
The insertvalue instruction is required to lower cir.complex.create because complex values are lowered to LLVM aggregate values, and thus we need to construct the aggregate value entirely in LLVM registers. But this is not the way the upstream CodeGen currently handles complex values. For the C code listed above, the upstream CodeGen would emit code like the following:
Basically the upstream CodeGen breaks the big store of aggregate values down to small stores of fields. To keep consistent LLVM IR codegen, we need further canonicalization passes to track the data flow of SSA values created by the cir.complex.create operation and breaks it into its real part and imaginary part. To give an example, after the canonicalization, the code generated by CIRGen above should be similar to:
Consider the following example:
CIRGen emits code similar to the following:
Then LLVMIR lowering pass further emits code similar to the following:
The
insertvalue
instruction is required to lowercir.complex.create
because complex values are lowered to LLVM aggregate values, and thus we need to construct the aggregate value entirely in LLVM registers. But this is not the way the upstream CodeGen currently handles complex values. For the C code listed above, the upstream CodeGen would emit code like the following:Basically the upstream CodeGen breaks the big store of aggregate values down to small stores of fields. To keep consistent LLVM IR codegen, we need further canonicalization passes to track the data flow of SSA values created by the
cir.complex.create
operation and breaks it into its real part and imaginary part. To give an example, after the canonicalization, the code generated by CIRGen above should be similar to:The text was updated successfully, but these errors were encountered: