[InstCombine] Create new log2 intrinsic; NFCI
authorNikita Popov <nikita.ppv@gmail.com>
Sun, 16 Feb 2020 09:15:53 +0000 (10:15 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Sun, 16 Feb 2020 14:52:09 +0000 (15:52 +0100)
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

index 5b82558..bf3e025 100644 (file)
@@ -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);
     }