mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-25 21:18:19 +00:00
Optimize square root squared (PR21126).
When unsafe-fp-math is enabled, we can turn sqrt(X) * sqrt(X) into X. This can happen in the real world when calculating x ** 3/2. This occurs in test-suite/SingleSource/Benchmarks/BenchmarkGame/n-body.c. Differential Revision: http://reviews.llvm.org/D5584 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218906 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -531,6 +531,11 @@ Instruction *InstCombiner::visitFMul(BinaryOperator &I) {
|
||||
}
|
||||
}
|
||||
|
||||
// sqrt(X) * sqrt(X) -> X
|
||||
if (AllowReassociate && (Op0 == Op1))
|
||||
if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(Op0))
|
||||
if (II->getIntrinsicID() == Intrinsic::sqrt)
|
||||
return ReplaceInstUsesWith(I, II->getOperand(0));
|
||||
|
||||
// Under unsafe algebra do:
|
||||
// X * log2(0.5*Y) = X*log2(Y) - X
|
||||
|
||||
Reference in New Issue
Block a user