Hi,
I try to understand why llvm can’t optimize this small piece of code.
My expectation is that the IR will be optimized to a “ ret i64 2101545.
But somehow the alias analysis fails when the pointer is casted to an integer value,
so the dead code eliminator can’t optimize it away.
Could someone explain to me why this is failing and if there is a solution for that ?
I can trick the alias analysis by setting %5 to a concrete integer so the code can be optimized further,
but I’m still wondering why llvm can’t do it.
Thanks,
Peter
define dso_local i64 @func(i64, i64, i64) local_unnamed_addr #0 {
.split:
%3 = alloca [100 x i64], align 16
%4 = getelementptr inbounds [100 x i64], [100 x i64]* %3, i64 0, i64 2
%5 = ptrtoint i64* %4 to i64
%6 = add i64 %5, -8
%7 = inttoptr i64 %6 to i64*
store i64 0, i64* %7, align 8
%8 = add i64 %5, -12
%9 = inttoptr i64 %8 to i32*
store i32 0, i32* %9, align 4
%10 = add i64 %5, -16
%11 = inttoptr i64 %10 to i32*
store i32 0, i32* %11, align 16
ret i64 2101545
}