[PATCH] D27587: Add "X / 1.0" to SimplifyFDivInst
Zia Ansari via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 9 04:01:57 PST 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289153: [InstSimplify] Add "X / 1.0" to SimplifyFDivInst. (authored by zansari).
Changed prior to commit:
https://reviews.llvm.org/D27587?vs=80814&id=80882#toc
Repository:
rL LLVM
https://reviews.llvm.org/D27587
Files:
llvm/trunk/lib/Analysis/InstructionSimplify.cpp
llvm/trunk/test/Transforms/InstSimplify/floating-point-arithmetic.ll
Index: llvm/trunk/test/Transforms/InstSimplify/floating-point-arithmetic.ll
===================================================================
--- llvm/trunk/test/Transforms/InstSimplify/floating-point-arithmetic.ll
+++ llvm/trunk/test/Transforms/InstSimplify/floating-point-arithmetic.ll
@@ -62,12 +62,10 @@
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
Index: llvm/trunk/lib/Analysis/InstructionSimplify.cpp
===================================================================
--- llvm/trunk/lib/Analysis/InstructionSimplify.cpp
+++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp
@@ -1127,6 +1127,10 @@
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 @@
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);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27587.80882.patch
Type: text/x-patch
Size: 1473 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161209/59c72ecc/attachment.bin>
More information about the llvm-commits
mailing list