< prev index next >

src/share/vm/opto/loopopts.cpp

Print this page


   1 /*
   2  * Copyright (c) 1999, 2016, 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  *


1893     }
1894   }
1895 
1896 }
1897 
1898 
1899 //---------------------- stride_of_possible_iv -------------------------------------
1900 // Looks for an iff/bool/comp with one operand of the compare
1901 // being a cycle involving an add and a phi,
1902 // with an optional truncation (left-shift followed by a right-shift)
1903 // of the add. Returns zero if not an iv.
1904 int PhaseIdealLoop::stride_of_possible_iv(Node* iff) {
1905   Node* trunc1 = NULL;
1906   Node* trunc2 = NULL;
1907   const TypeInt* ttype = NULL;
1908   if (!iff->is_If() || iff->in(1) == NULL || !iff->in(1)->is_Bool()) {
1909     return 0;
1910   }
1911   BoolNode* bl = iff->in(1)->as_Bool();
1912   Node* cmp = bl->in(1);
1913   if (!cmp || cmp->Opcode() != Op_CmpI && cmp->Opcode() != Op_CmpU) {
1914     return 0;
1915   }
1916   // Must have an invariant operand
1917   if (is_member(get_loop(iff), get_ctrl(cmp->in(2)))) {
1918     return 0;
1919   }
1920   Node* add2 = NULL;
1921   Node* cmp1 = cmp->in(1);
1922   if (cmp1->is_Phi()) {
1923     // (If (Bool (CmpX phi:(Phi ...(Optional-trunc(AddI phi add2))) )))
1924     Node* phi = cmp1;
1925     for (uint i = 1; i < phi->req(); i++) {
1926       Node* in = phi->in(i);
1927       Node* add = CountedLoopNode::match_incr_with_optional_truncation(in,
1928                                 &trunc1, &trunc2, &ttype);
1929       if (add && add->in(1) == phi) {
1930         add2 = add->in(2);
1931         break;
1932       }
1933     }


   1 /*
   2  * Copyright (c) 1999, 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  *


1893     }
1894   }
1895 
1896 }
1897 
1898 
1899 //---------------------- stride_of_possible_iv -------------------------------------
1900 // Looks for an iff/bool/comp with one operand of the compare
1901 // being a cycle involving an add and a phi,
1902 // with an optional truncation (left-shift followed by a right-shift)
1903 // of the add. Returns zero if not an iv.
1904 int PhaseIdealLoop::stride_of_possible_iv(Node* iff) {
1905   Node* trunc1 = NULL;
1906   Node* trunc2 = NULL;
1907   const TypeInt* ttype = NULL;
1908   if (!iff->is_If() || iff->in(1) == NULL || !iff->in(1)->is_Bool()) {
1909     return 0;
1910   }
1911   BoolNode* bl = iff->in(1)->as_Bool();
1912   Node* cmp = bl->in(1);
1913   if (!cmp || (cmp->Opcode() != Op_CmpI && cmp->Opcode() != Op_CmpU)) {
1914     return 0;
1915   }
1916   // Must have an invariant operand
1917   if (is_member(get_loop(iff), get_ctrl(cmp->in(2)))) {
1918     return 0;
1919   }
1920   Node* add2 = NULL;
1921   Node* cmp1 = cmp->in(1);
1922   if (cmp1->is_Phi()) {
1923     // (If (Bool (CmpX phi:(Phi ...(Optional-trunc(AddI phi add2))) )))
1924     Node* phi = cmp1;
1925     for (uint i = 1; i < phi->req(); i++) {
1926       Node* in = phi->in(i);
1927       Node* add = CountedLoopNode::match_incr_with_optional_truncation(in,
1928                                 &trunc1, &trunc2, &ttype);
1929       if (add && add->in(1) == phi) {
1930         add2 = add->in(2);
1931         break;
1932       }
1933     }


< prev index next >