[llvm-dev] Little explanation of this behaviour
Lorenzo Laneve via llvm-dev
llvm-dev at lists.llvm.org
Thu Apr 14 15:44:28 PDT 2016
I tried to emit IR for a function that returns the sum between an signed char and a double in C++, just to see how Clang handles type implicit casting.
Can you explain me why Clang converted the char type into a 32-bit integer type before casting it to a floating point? Can a sitofp i8 %3 to double be done or is it wrong?
define i32 @_Z5sumad(i8 signext %x, double %y) #0 {
%1 = alloca i8, align 1
%2 = alloca double, align 8
store i8 %x, i8* %1, align 1
store double %y, double* %2, align 8
%3 = load i8, i8* %1, align 1
%4 = sext i8 %3 to i32
%5 = sitofp i32 %4 to double
%6 = load double, double* %2, align 8
%7 = fadd double %5, %6
%8 = fptosi double %7 to i32
ret i32 %8
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160415/8c96dff2/attachment.html>
More information about the llvm-dev
mailing list