From 893c630fbe393916d9b7e07a5ac58046ea5db30e Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Sun, 16 Feb 2020 10:15:53 +0100 Subject: [PATCH] [InstCombine] Create new log2 intrinsic; NFCI Rather than mixing creation of new instructions and in-place modification here, create a new log2 intrinsic. This should be NFC apart from worklist order changes. --- llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp index 5b825581a32f..bf3e025697a3 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp @@ -563,8 +563,7 @@ Instruction *InstCombiner::visitFMul(BinaryOperator &I) { Y = Op0; } if (Log2) { - Log2->setArgOperand(0, X); - Log2->copyFastMathFlags(&I); + Value *Log2 = Builder.CreateUnaryIntrinsic(Intrinsic::log2, X, &I); Value *LogXTimesY = Builder.CreateFMulFMF(Log2, Y, &I); return BinaryOperator::CreateFSubFMF(LogXTimesY, Y, &I); }