[llvm-dev] Need help in understanding llvm optimization

SANGEETA CHOWDHARY via llvm-dev llvm-dev at lists.llvm.org
Sat Aug 11 12:30:14 PDT 2018


Hi,

I have below code in C -

int main() {

  double x,y;

  x = 1e16;

  y = (x + 1) - x;

  printf("y:%e\n", y);

  return 0;

}

llvm bitcode looks like this for this function -


; Function Attrs: nounwind uwtable

define dso_local i32 @main() local_unnamed_addr #0 {

entry:

  %call = tail call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x
i8], [4 x i8]* @.str, i64 0, i64 0), double 0.000000e+00)

  ret i32 0

}

I am not able to understand how addition and subtraction are performed in
this code. There is no fadd or fsub instruction. How llvm knows that result
of y is 0?

Is there any way to disable this in llvm?


Any help would be much appreciated.


Regards,

Sangeeta
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180811/7e03ffa5/attachment.html>


More information about the llvm-dev mailing list