summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2019-04-03 00:25:06 +0000
committerMatt Arsenault <Matthew.Arsenault@amd.com>2019-04-03 00:25:06 +0000
commit03e74928762edd4ac74af7f9b7acb6c672f13d1e (patch)
tree87ec7da9c9ee018833d70c0c8cc57e3852939b66 /llvm/lib
parentef4c66c1c83bbb58643c66b4e290a56e9991d5ca (diff)
downloadbcm5719-llvm-03e74928762edd4ac74af7f9b7acb6c672f13d1e.tar.gz
bcm5719-llvm-03e74928762edd4ac74af7f9b7acb6c672f13d1e.zip
InstSimplify: Fold round intrinsics from sitofp/uitofp
https://godbolt.org/z/gEMRZb llvm-svn: 357549
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Analysis/InstructionSimplify.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index 851306bfe20..c1ae23c6727 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -4701,6 +4701,22 @@ static Value *simplifyUnaryIntrinsic(Function *F, Value *Op0,
match(Op0, m_Intrinsic<Intrinsic::pow>(m_SpecificFP(10.0),
m_Value(X)))) return X;
break;
+ case Intrinsic::floor:
+ case Intrinsic::trunc:
+ case Intrinsic::ceil:
+ case Intrinsic::round:
+ case Intrinsic::nearbyint:
+ case Intrinsic::rint: {
+ // floor (sitofp x) -> sitofp x
+ // floor (uitofp x) -> uitofp x
+ //
+ // Converting from int always results in a finite integral number or
+ // infinity. For either of those inputs, these rounding functions always
+ // return the same value, so the rounding can be eliminated.
+ if (match(Op0, m_SIToFP(m_Value())) || match(Op0, m_UIToFP(m_Value())))
+ return Op0;
+ break;
+ }
default:
break;
}
OpenPOWER on IntegriCloud