[llvm-branch-commits] [llvm-branch] r143013 - in /llvm/branches/release_30: ./ lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Bill Wendling isanbard at gmail.com
Tue Oct 25 21:25:53 PDT 2011


Author: void
Date: Tue Oct 25 23:25:53 2011
New Revision: 143013

URL: http://llvm.org/viewvc/llvm-project?rev=143013&view=rev
Log:
Merging r143006:
------------------------------------------------------------------------
r143006 | stoklund | 2011-10-25 18:47:48 -0700 (Tue, 25 Oct 2011) | 8 lines

Don't use floating point to do an integer's job.

This code makes different decisions when compiled into x87 instructions
because of different rounding behavior.  That caused phase 2/3
miscompares on 32-bit Linux when the phase 1 compiler was built with gcc
(using x87), and the phase 2 compiler was built with clang (using SSE).

This fixes PR11200.
------------------------------------------------------------------------

Modified:
    llvm/branches/release_30/   (props changed)
    llvm/branches/release_30/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Propchange: llvm/branches/release_30/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Oct 25 23:25:53 2011
@@ -1,3 +1,3 @@
 /llvm/branches/Apple/Pertwee:110850,110961
 /llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:142039,142055,142058,142112,142123,142125,142165,142168,142243,142350,142482,142486,142489,142491-142493,142537,142550,142559,142573-142574,142801,142806,142841,142869,142956
+/llvm/trunk:142039,142055,142058,142112,142123,142125,142165,142168,142243,142350,142482,142486,142489,142491-142493,142537,142550,142559,142573-142574,142801,142806,142841,142869,142956,143006

Modified: llvm/branches/release_30/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_30/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=143013&r1=143012&r2=143013&view=diff
==============================================================================
--- llvm/branches/release_30/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original)
+++ llvm/branches/release_30/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Tue Oct 25 23:25:53 2011
@@ -2034,14 +2034,17 @@
     return false;
 
   APInt Range = ComputeRange(First, Last);
-  double Density = TSize.roundToDouble() / Range.roundToDouble();
-  if (Density < 0.4)
+  // The density is TSize / Range. Require at least 40%.
+  // It should not be possible for IntTSize to saturate for sane code, but make
+  // sure we handle Range saturation correctly.
+  uint64_t IntRange = Range.getLimitedValue(UINT64_MAX/10);
+  uint64_t IntTSize = TSize.getLimitedValue(UINT64_MAX/10);
+  if (IntTSize * 10 < IntRange * 4)
     return false;
 
   DEBUG(dbgs() << "Lowering jump table\n"
                << "First entry: " << First << ". Last entry: " << Last << '\n'
-               << "Range: " << Range
-               << ". Size: " << TSize << ". Density: " << Density << "\n\n");
+               << "Range: " << Range << ". Size: " << TSize << ".\n\n");
 
   // Get the MachineFunction which holds the current MBB.  This is used when
   // inserting any additional MBBs necessary to represent the switch.





More information about the llvm-branch-commits mailing list