diff options
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp index be4d459..fb2efe5 100644 --- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp @@ -2758,14 +2758,17 @@ Value *LibCallSimplifier::optimizeSqrt(CallInst *CI, IRBuilderBase &B) { // Note: We don't bother looking any deeper than this first level or for // variations of this pattern because instcombine's visitFMUL and/or the // reassociation pass should give us this form. - Value *OtherMul0, *OtherMul1; - if (match(Op0, m_FMul(m_Value(OtherMul0), m_Value(OtherMul1)))) { - // Pattern: sqrt((x * y) * z) - if (OtherMul0 == OtherMul1 && cast<Instruction>(Op0)->isFast()) { - // Matched: sqrt((x * x) * z) - RepeatOp = OtherMul0; - OtherOp = Op1; - } + Value *MulOp; + if (match(Op0, m_FMul(m_Value(MulOp), m_Deferred(MulOp))) && + cast<Instruction>(Op0)->isFast()) { + // Pattern: sqrt((x * x) * z) + RepeatOp = MulOp; + OtherOp = Op1; + } else if (match(Op1, m_FMul(m_Value(MulOp), m_Deferred(MulOp))) && + cast<Instruction>(Op1)->isFast()) { + // Pattern: sqrt(z * (x * x)) + RepeatOp = MulOp; + OtherOp = Op0; } } if (!RepeatOp) |