1 /* 2 * Copyright (c) 2020, 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 */ 23 24 /* 25 * @test 26 * @bug 8249602 27 * @summary Tests the rewiring and cloning of fall-in values from the main loop (and pre loop) to the post (and main loop) 28 * which resulted in a DUIterator_Fast assertion failure due to an insertion in the outputs of the loop header node. 29 * 30 * @run main compiler.loopopts.TestPreMainPostFallInEdges 31 */ 32 33 package compiler.loopopts; 34 35 public class TestPreMainPostFallInEdges { 36 test()37 public static int test() { 38 int iArr[] = new int[400]; 39 float fArr[] = new float[400]; 40 int x = 0; 41 byte y = 124; 42 short z = 0; 43 44 int i = 1; 45 do { 46 int j = 1; 47 do { 48 z *= 11; 49 50 // These 4 array stores live in the back control block and cannot float. They are cloned and their control input set to the preheader control 51 // block of the post loop. If their input edges also have their placement in the back control block (get_ctrl == back control) then they are 52 // cloned as well. The following code hits the assertion failure when we clone a node with a control edge to the loop header block of the main. 53 // loop. The DUIterator_Fast does not allow insertions. The fix is to replace it by a normal DUIterator which allows insertions. 54 iArr[j] = 3; 55 // load of iArr[j + 1] is also cloned but has a control edge to the main loop header block hitting the assertion failure. 56 iArr[j + 1] += 4; 57 fArr[j] = 5; 58 fArr[j + 1] += fArr[j + 5]; // same for load of fArr[j + 1] and load of fArr[j + 5] 59 60 int k = 1; 61 do { 62 iArr[j] *= 324; 63 x = 34; 64 y *= 54; 65 } while (k < 1); 66 } while (++j < 6); 67 } while (++i < 289); 68 return checkSum(iArr) + checkSum(fArr); 69 } 70 checkSum(int[] a)71 public static int checkSum(int[] a) { 72 int sum = 0; 73 for (int j = 0; j < a.length; j++) { 74 sum += a[j] % (j + 1); 75 } 76 return sum; 77 } 78 checkSum(float[] a)79 public static int checkSum(float[] a) { 80 int sum = 0; 81 for (int j = 0; j < a.length; j++) { 82 sum += a[j] % (j + 1); 83 } 84 return sum; 85 } 86 main(String[] strArr)87 public static void main(String[] strArr) { 88 for (int i = 0; i < 10000; i++) { 89 test(); 90 } 91 } 92 } 93 94