summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorZia Ansari <zia.ansari@intel.com>2016-12-08 23:27:40 +0000
committerZia Ansari <zia.ansari@intel.com>2016-12-08 23:27:40 +0000
commit394cef803a401163a1ad2d472fcd117c68ef2eef (patch)
tree3796ce36a336d1bb1f676cfcf57d0786c60603af /llvm
parent95c7d8d2a7b02bf56132ca137f3960bd917ea84b (diff)
downloadbcm5719-llvm-394cef803a401163a1ad2d472fcd117c68ef2eef.tar.gz
bcm5719-llvm-394cef803a401163a1ad2d472fcd117c68ef2eef.zip
[InstSimplify] Add "X / 1.0" to SimplifyFDivInst.
Differential Revision: https://reviews.llvm.org/D27587 llvm-svn: 289153
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Analysis/InstructionSimplify.cpp6
-rw-r--r--llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll4
2 files changed, 7 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index bbabf2af691..e620e09f5db 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -1127,6 +1127,10 @@ static Value *SimplifyFDivInst(Value *Op0, Value *Op1, FastMathFlags FMF,
if (match(Op1, m_Undef()))
return Op1;
+ // X / 1.0 -> X
+ if (match(Op1, m_FPOne()))
+ return Op0;
+
// 0 / X -> 0
// Requires that NaNs are off (X could be zero) and signed zeroes are
// ignored (X could be positive or negative, so the output sign is unknown).
@@ -4093,6 +4097,8 @@ static Value *SimplifyFPBinOp(unsigned Opcode, Value *LHS, Value *RHS,
return SimplifyFSubInst(LHS, RHS, FMF, Q, MaxRecurse);
case Instruction::FMul:
return SimplifyFMulInst(LHS, RHS, FMF, Q, MaxRecurse);
+ case Instruction::FDiv:
+ return SimplifyFDivInst(LHS, RHS, FMF, Q, MaxRecurse);
default:
return SimplifyBinOp(Opcode, LHS, RHS, Q, MaxRecurse);
}
diff --git a/llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll b/llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll
index ef8adcb1646..21c9fdde150 100644
--- a/llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll
+++ b/llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll
@@ -62,12 +62,10 @@ define double @fmul_X_1(double %a) {
ret double %b
}
-; FIXME:
; fdiv X, 1.0 ==> X
define float @fdiv_x_1(float %a) {
; CHECK-LABEL: @fdiv_x_1(
-; CHECK-NEXT: [[RET:%.*]] = fdiv float %a, 1.000000e+00
-; CHECK-NEXT: ret float [[RET]]
+; CHECK-NEXT: ret float %a
;
%ret = fdiv float %a, 1.0
ret float %ret
OpenPOWER on IntegriCloud