[llvm] 893c630 - [InstCombine] Create new log2 intrinsic; NFCI

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 16 06:55:40 PST 2020


Author: Nikita Popov
Date: 2020-02-16T15:52:09+01:00
New Revision: 893c630fbe393916d9b7e07a5ac58046ea5db30e

URL: https://github.com/llvm/llvm-project/commit/893c630fbe393916d9b7e07a5ac58046ea5db30e
DIFF: https://github.com/llvm/llvm-project/commit/893c630fbe393916d9b7e07a5ac58046ea5db30e.diff

LOG: [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.

Added: 
    

Modified: 
    llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp

Removed: 
    


################################################################################
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);
     }


        


More information about the llvm-commits mailing list