8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "memory/allocation.inline.hpp"
27 #include "opto/addnode.hpp"
28 #include "opto/connode.hpp"
29 #include "opto/divnode.hpp"
30 #include "opto/machnode.hpp"
31 #include "opto/matcher.hpp"
32 #include "opto/mulnode.hpp"
33 #include "opto/phaseX.hpp"
34 #include "opto/subnode.hpp"
35
36 // Portions of code courtesy of Clifford Click
37
38 // Optimization - Graph Style
39
40 #include <math.h>
41
42 //----------------------magic_int_divide_constants-----------------------------
43 // Compute magic multiplier and shift constant for converting a 32 bit divide
44 // by constant into a multiply/shift/add series. Return false if calculations
45 // fail.
46 //
47 // Borrowed almost verbatim from Hacker's Delight by Henry S. Warren, Jr. with
48 // minor type name and parameter changes.
49 static bool magic_int_divide_constants(jint d, jint &M, jint &s) {
50 int32_t p;
|
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "memory/allocation.inline.hpp"
27 #include "opto/addnode.hpp"
28 #include "opto/constnode.hpp"
29 #include "opto/convertnode.hpp"
30 #include "opto/divnode.hpp"
31 #include "opto/machnode.hpp"
32 #include "opto/movenode.hpp"
33 #include "opto/matcher.hpp"
34 #include "opto/mulnode.hpp"
35 #include "opto/phaseX.hpp"
36 #include "opto/subnode.hpp"
37
38 // Portions of code courtesy of Clifford Click
39
40 // Optimization - Graph Style
41
42 #include <math.h>
43
44 //----------------------magic_int_divide_constants-----------------------------
45 // Compute magic multiplier and shift constant for converting a 32 bit divide
46 // by constant into a multiply/shift/add series. Return false if calculations
47 // fail.
48 //
49 // Borrowed almost verbatim from Hacker's Delight by Henry S. Warren, Jr. with
50 // minor type name and parameter changes.
51 static bool magic_int_divide_constants(jint d, jint &M, jint &s) {
52 int32_t p;
|