[llvm] r289153 - [InstSimplify] Add "X / 1.0" to SimplifyFDivInst.
Zia Ansari via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 8 15:27:41 PST 2016
Author: zansari
Date: Thu Dec 8 17:27:40 2016
New Revision: 289153
URL: http://llvm.org/viewvc/llvm-project?rev=289153&view=rev
Log:
[InstSimplify] Add "X / 1.0" to SimplifyFDivInst.
Differential Revision: https://reviews.llvm.org/D27587
Modified:
llvm/trunk/lib/Analysis/InstructionSimplify.cpp
llvm/trunk/test/Transforms/InstSimplify/floating-point-arithmetic.ll
Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=289153&r1=289152&r2=289153&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original)
+++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Thu Dec 8 17:27:40 2016
@@ -1127,6 +1127,10 @@ static Value *SimplifyFDivInst(Value *Op
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 O
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);
}
Modified: llvm/trunk/test/Transforms/InstSimplify/floating-point-arithmetic.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstSimplify/floating-point-arithmetic.ll?rev=289153&r1=289152&r2=289153&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstSimplify/floating-point-arithmetic.ll (original)
+++ llvm/trunk/test/Transforms/InstSimplify/floating-point-arithmetic.ll Thu Dec 8 17:27:40 2016
@@ -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
More information about the llvm-commits
mailing list