1 /*
2 * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
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 *
645 // Note, counted loop's test is '<' or '>'.
646 limit = exact_limit(loop);
647 max_idx_expr = new SubINode(limit, stride);
648 register_new_node(max_idx_expr, ctrl);
649 if (TraceLoopPredicate) predString->print("(limit - stride) ");
650 } else {
651 if (TraceLoopPredicate) predString->print("init ");
652 }
653
654 if (scale != 1) {
655 ConNode* con_scale = _igvn.intcon(scale);
656 set_ctrl(con_scale, C->root());
657 max_idx_expr = new MulINode(max_idx_expr, con_scale);
658 register_new_node(max_idx_expr, ctrl);
659 if (TraceLoopPredicate) predString->print("* %d ", scale);
660 }
661
662 if (offset && (!offset->is_Con() || offset->get_int() != 0)){
663 max_idx_expr = new AddINode(max_idx_expr, offset);
664 register_new_node(max_idx_expr, ctrl);
665 if (TraceLoopPredicate)
666 if (offset->is_Con()) predString->print("+ %d ", offset->get_int());
667 else predString->print("+ offset ");
668 }
669
670 CmpUNode* cmp = new CmpUNode(max_idx_expr, range);
671 register_new_node(cmp, ctrl);
672 BoolNode* bol = new BoolNode(cmp, BoolTest::lt);
673 register_new_node(bol, ctrl);
674
675 if (TraceLoopPredicate) {
676 predString->print_cr("<u range");
677 tty->print("%s", predString->as_string());
678 }
679 return bol;
680 }
681
682 //------------------------------ loop_predication_impl--------------------------
683 // Insert loop predicates for null checks and range checks
684 bool PhaseIdealLoop::loop_predication_impl(IdealLoopTree *loop) {
685 if (!UseLoopPredicate) return false;
686
687 if (!loop->_head->is_Loop()) {
|
1 /*
2 * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
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 *
645 // Note, counted loop's test is '<' or '>'.
646 limit = exact_limit(loop);
647 max_idx_expr = new SubINode(limit, stride);
648 register_new_node(max_idx_expr, ctrl);
649 if (TraceLoopPredicate) predString->print("(limit - stride) ");
650 } else {
651 if (TraceLoopPredicate) predString->print("init ");
652 }
653
654 if (scale != 1) {
655 ConNode* con_scale = _igvn.intcon(scale);
656 set_ctrl(con_scale, C->root());
657 max_idx_expr = new MulINode(max_idx_expr, con_scale);
658 register_new_node(max_idx_expr, ctrl);
659 if (TraceLoopPredicate) predString->print("* %d ", scale);
660 }
661
662 if (offset && (!offset->is_Con() || offset->get_int() != 0)){
663 max_idx_expr = new AddINode(max_idx_expr, offset);
664 register_new_node(max_idx_expr, ctrl);
665 if (TraceLoopPredicate) {
666 if (offset->is_Con()) {
667 predString->print("+ %d ", offset->get_int());
668 } else {
669 predString->print("+ offset ");
670 }
671 }
672 }
673
674 CmpUNode* cmp = new CmpUNode(max_idx_expr, range);
675 register_new_node(cmp, ctrl);
676 BoolNode* bol = new BoolNode(cmp, BoolTest::lt);
677 register_new_node(bol, ctrl);
678
679 if (TraceLoopPredicate) {
680 predString->print_cr("<u range");
681 tty->print("%s", predString->as_string());
682 }
683 return bol;
684 }
685
686 //------------------------------ loop_predication_impl--------------------------
687 // Insert loop predicates for null checks and range checks
688 bool PhaseIdealLoop::loop_predication_impl(IdealLoopTree *loop) {
689 if (!UseLoopPredicate) return false;
690
691 if (!loop->_head->is_Loop()) {
|