diff options
author | Duncan Sands <baldrick@free.fr> | 2012-04-10 20:35:27 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2012-04-10 20:35:27 +0000 |
commit | 507bb7a42fce6502f90268712cbc32158c17bb59 (patch) | |
tree | 44d94c76c0038d4aa74b10a504e7966fd17444f1 | |
parent | 3ecb447f52d169dea6663b95b5b5b43e9bb5826b (diff) |
Add a comment noting that the fdiv -> fmul conversion won't generate
multiplication by a denormal, and some tests checking that.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154431 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 6 | ||||
-rw-r--r-- | test/CodeGen/X86/fdiv.ll | 16 |
2 files changed, 19 insertions, 3 deletions
diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index b5b20284c1..ae7c941b13 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -5769,9 +5769,9 @@ SDValue DAGCombiner::visitFDIV(SDNode *N) { APFloat N1APF = N1CFP->getValueAPF(); APFloat Recip(N1APF.getSemantics(), 1); // 1.0 APFloat::opStatus st = Recip.divide(N1APF, APFloat::rmNearestTiesToEven); - // Only do the transform if the reciprocal is not too horrible (eg not NaN) - // and the reciprocal is a legal fp imm. - if ((st == APFloat::opOK || st == APFloat::opInexact) && + // Only do the transform if the reciprocal is a legal fp immediate that + // isn't too nasty (eg NaN, denormal, ...). + if ((st == APFloat::opOK || st == APFloat::opInexact) && // Not too nasty (!LegalOperations || // FIXME: custom lowering of ConstantFP might fail (see e.g. ARM // backend)... we should handle this gracefully after Legalize. diff --git a/test/CodeGen/X86/fdiv.ll b/test/CodeGen/X86/fdiv.ll index 82b9190b9a..0749682e2f 100644 --- a/test/CodeGen/X86/fdiv.ll +++ b/test/CodeGen/X86/fdiv.ll @@ -23,3 +23,19 @@ define double @funky(double %x) { %div = fdiv double %x, 0.0 ret double %div } + +define double @denormal1(double %x) { +; Don't generate multiplication by a denormal. +; CHECK: @denormal1 +; CHECK: divsd + %div = fdiv double %x, 0x7FD0000000000001 + ret double %div +} + +define double @denormal2(double %x) { +; Don't generate multiplication by a denormal. +; CHECK: @denormal +; CHECK: divsd + %div = fdiv double %x, 0x7FEFFFFFFFFFFFFF + ret double %div +} |