[llvm] r329503 - [InstCombine] simplify code that propagates FMF; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 7 07:14:24 PDT 2018
Author: spatel
Date: Sat Apr 7 07:14:23 2018
New Revision: 329503
URL: http://llvm.org/viewvc/llvm-project?rev=329503&view=rev
Log:
[InstCombine] simplify code that propagates FMF; NFC
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp?rev=329503&r1=329502&r2=329503&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp Sat Apr 7 07:14:23 2018
@@ -1544,9 +1544,7 @@ Instruction *InstCombiner::visitFPTrunc(
if (OpWidth >= LHSWidth + RHSWidth && DstWidth >= SrcWidth) {
Value *LHS = Builder.CreateFPTrunc(OpI->getOperand(0), Ty);
Value *RHS = Builder.CreateFPTrunc(OpI->getOperand(1), Ty);
- Instruction *RI = BinaryOperator::CreateFMul(LHS, RHS);
- RI->copyFastMathFlags(OpI);
- return RI;
+ return BinaryOperator::CreateFMulFMF(LHS, RHS, OpI);
}
break;
case Instruction::FDiv:
@@ -1559,9 +1557,7 @@ Instruction *InstCombiner::visitFPTrunc(
if (OpWidth >= 2*DstWidth && DstWidth >= SrcWidth) {
Value *LHS = Builder.CreateFPTrunc(OpI->getOperand(0), Ty);
Value *RHS = Builder.CreateFPTrunc(OpI->getOperand(1), Ty);
- Instruction *RI = BinaryOperator::CreateFDiv(LHS, RHS);
- RI->copyFastMathFlags(OpI);
- return RI;
+ return BinaryOperator::CreateFDivFMF(LHS, RHS, OpI);
}
break;
case Instruction::FRem: {
@@ -1580,9 +1576,7 @@ Instruction *InstCombiner::visitFPTrunc(
RHS = Builder.CreateFPTrunc(OpI->getOperand(1), RHSMinType);
}
- Value *ExactResult = Builder.CreateFRem(LHS, RHS);
- if (Instruction *RI = dyn_cast<Instruction>(ExactResult))
- RI->copyFastMathFlags(OpI);
+ Value *ExactResult = Builder.CreateFRemFMF(LHS, RHS, OpI);
return CastInst::CreateFPCast(ExactResult, Ty);
}
}
@@ -1590,9 +1584,7 @@ Instruction *InstCombiner::visitFPTrunc(
// (fptrunc (fneg x)) -> (fneg (fptrunc x))
if (BinaryOperator::isFNeg(OpI)) {
Value *InnerTrunc = Builder.CreateFPTrunc(OpI->getOperand(1), Ty);
- Instruction *RI = BinaryOperator::CreateFNeg(InnerTrunc);
- RI->copyFastMathFlags(OpI);
- return RI;
+ return BinaryOperator::CreateFNegFMF(InnerTrunc, OpI);
}
}
More information about the llvm-commits
mailing list