llvm.org GIT mirror llvm / b0e9ead
fix several bugs in the tutorial, patch by Kevin Kelley! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106498 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 9 years ago
4 changed file(s) with 6 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
366366 if (L == 0 || R == 0) return 0;
367367
368368 switch (Op) {
369 case '+': return Builder.CreateAdd(L, R, "addtmp");
370 case '-': return Builder.CreateSub(L, R, "subtmp");
371 case '*': return Builder.CreateMul(L, R, "multmp");
369 case '+': return Builder.CreateFAdd(L, R, "addtmp");
370 case '-': return Builder.CreateFSub(L, R, "subtmp");
371 case '*': return Builder.CreateFMul(L, R, "multmp");
372372 case '<':
373373 L = Builder.CreateFCmpULT(L, R, "cmptmp");
374374 // Convert bool 0/1 to double 0.0 or 1.0
614614 StepVal = ConstantFP::get(getGlobalContext(), APFloat(1.0));
615615 }
616616
617 Value *NextVar = Builder.CreateAdd(Variable, StepVal, "nextvar");
617 Value *NextVar = Builder.CreateFAdd(Variable, StepVal, "nextvar");
618618
619619 // Compute the end condition.
620620 Value *EndCond = End->Codegen();
718718 StepVal = ConstantFP::get(getGlobalContext(), APFloat(1.0));
719719 }
720720
721 Value *NextVar = Builder.CreateAdd(Variable, StepVal, "nextvar");
721 Value *NextVar = Builder.CreateFAdd(Variable, StepVal, "nextvar");
722722
723723 // Compute the end condition.
724724 Value *EndCond = End->Codegen();
827827 // Reload, increment, and restore the alloca. This handles the case where
828828 // the body of the loop mutates the variable.
829829 Value *CurVar = Builder.CreateLoad(Alloca, VarName.c_str());
830 Value *NextVar = Builder.CreateAdd(CurVar, StepVal, "nextvar");
830 Value *NextVar = Builder.CreateFAdd(CurVar, StepVal, "nextvar");
831831 Builder.CreateStore(NextVar, Alloca);
832832
833833 // Convert condition to a bool by comparing equal to 0.0.