Path: blob/master/test/hotspot/jtreg/compiler/loopopts/PartialPeelingUnswitch.java
41149 views
/*1* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @requires vm.compiler2.enabled26* @bug 8233033 8235984 824022727* @summary Tests if partially peeled statements are not executed before the loop predicates by bailing out of loop unswitching.28*29* @run main/othervm -Xbatch -XX:LoopStripMiningIter=030* -XX:CompileCommand=compileonly,compiler.loopopts.PartialPeelingUnswitch::test*31* -XX:CompileCommand=dontinline,compiler.loopopts.PartialPeelingUnswitch::dontInline*32* compiler.loopopts.PartialPeelingUnswitch33* @run main/othervm -Xbatch -Xcomp -XX:LoopStripMiningIter=034* -XX:CompileCommand=compileonly,compiler.loopopts.PartialPeelingUnswitch::test*35* -XX:CompileCommand=dontinline,compiler.loopopts.PartialPeelingUnswitch::dontInline*36* compiler.loopopts.PartialPeelingUnswitch37* @run main/othervm -Xbatch38* -XX:CompileCommand=compileonly,compiler.loopopts.PartialPeelingUnswitch::test*39* -XX:CompileCommand=dontinline,compiler.loopopts.PartialPeelingUnswitch::dontInline*40* compiler.loopopts.PartialPeelingUnswitch41* @run main/othervm -Xbatch -Xcomp42* -XX:CompileCommand=compileonly,compiler.loopopts.PartialPeelingUnswitch::test*43* -XX:CompileCommand=dontinline,compiler.loopopts.PartialPeelingUnswitch::dontInline*44* compiler.loopopts.PartialPeelingUnswitch45* @run main/othervm -Xbatch46* -XX:CompileCommand=compileonly,compiler.loopopts.PartialPeelingUnswitch::*47* -XX:CompileCommand=dontinline,compiler.loopopts.PartialPeelingUnswitch::dontInline*48* compiler.loopopts.PartialPeelingUnswitch49* @run main/othervm -Xbatch -Xcomp50* -XX:CompileCommand=compileonly,compiler.loopopts.PartialPeelingUnswitch::*51* -XX:CompileCommand=dontinline,compiler.loopopts.PartialPeelingUnswitch::dontInline*52* compiler.loopopts.PartialPeelingUnswitch53*/5455package compiler.loopopts;5657public class PartialPeelingUnswitch {5859public static int iFld;60public static int w = 88;61public static int x = 42;62public static int y = 31;63public static int z = 22;64public static int val = 34;65public static final int iCon = 20;6667public static int[] iArr = new int[10];6869public int test() {70/*71* The inner loop of this test is first partially peeled and then unswitched. An uncommon trap is hit in one72* of the cloned loop predicates for the fast loop (set up at unswitching stage). The only partially peeled73* statement "iFld += 7" was wrongly executed before the predicates (and before the loop itself).74* When hitting the uncommon trap, "iFld >>= 1" was not yet executed. As a result, the interpreter directly75* reexecuted "iFld += 7" again. This resulted in a wrong result for "iFld". The fix in 8233033 makes peeled76* statements control dependant on the cloned loop predicates such that they are executed after them. However,77* some cases are not handled properly. For now, the new fix in 8235984 just bails out of loop unswitching.78*/79iFld = 13;80for (int i = 0; i < 8; i++) {81int j = 10;82while (--j > 0) {83iFld += -7;84switch ((i * 5) + 102) {85case 120:86break;87case 103:88break;89case 116:90break;91default:92iFld >>= 1;93}94}95}96return iFld;97}9899public int test2() {100/*101* Same nested loop structure as in test() but with more statements that are partially peeled from the inner loop.102* Afterwards the inner loop is unswitched.103*/104iFld = 13;105int k = 0;106for (int i = 0; i < 8; i++) {107int j = 10;108while (--j > 0) {109// All statements before the switch expression are partially peeled110iFld += -7;111x = y + iFld;112y = iArr[5];113k = 6;114iArr[5] = 5;115iArr[6] += 23;116iArr[7] = iArr[8] + iArr[6];117iArr[j] = 34;118switch ((i * 5) + 102) {119case 120:120break;121case 103:122break;123case 116:124break;125default:126iFld >>= 1;127}128}129}130return iFld + k;131}132133public int test3() {134iFld = 13;135if (z < 34) {136z = 34;137}138139for (int i = 0; i < 8; i++) {140int j = 10;141while (--j > 0) {142iFld += -7;143iArr[5] = 8;144x = iArr[6];145y = x;146for (int k = 50; k < 51; k++) {147x = iArr[7];148}149switch ((i * 5) + 102) {150case 120:151return iFld;152case 103:153break;154case 116:155break;156default:157if (iFld == -7) {158return iFld;159}160z = iArr[5];161iFld >>= 1;162}163}164iArr[5] = 34;165dontInline(iArr[5]);166}167return iFld;168}169170public int test4() {171iFld = 13;172if (z < 34) {173z = 34;174}175176for (int i = 0; i < 8; i++) {177int j = 10;178while (--j > 0) {179iFld += -7;180iArr[5] = 8;181x = iArr[6];182y = x;183for (int k = 50; k < 51; k++) {184x = iArr[7];185}186switch ((i * 5) + 102) {187case 120:188return iFld;189case 103:190break;191case 116:192break;193default:194if (iFld == -7) {195return iFld;196}197z = iArr[5];198iFld >>= 1;199}200}201iArr[5] = 34;202}203return iFld;204}205206public int test5() {207iFld = 13;208for (int i = 0; i < 8; i++) {209int j = 10;210while (--j > 0) {211iFld += -7;212iArr[5] = 8;213x = iArr[6];214y = x;215for (int k = 50; k < 51; k++) {216x = iArr[7];217}218switch ((i * 5) + 102) {219case 120:220return iFld;221case 103:222break;223case 116:224break;225default:226iFld >>= 1;227}228}229}230return iFld;231}232233public int test6() {234iFld = 13;235for (int i = 0; i < 8; i++) {236int j = 10;237while (--j > 0) {238iFld += -7;239iArr[5] = 8;240x = iArr[6];241y = x;242switch ((i * 5) + 102) {243case 120:244return iFld;245case 103:246break;247case 116:248break;249default:250iFld >>= 1;251}252}253}254return iFld;255}256257public int test7() {258iFld = 13;259for (int i = 0; i < 8; i++) {260int j = 10;261while (--j > 0) {262iFld += -7;263iArr[5] = 8;264switch ((i * 5) + 102) {265case 120:266return iFld;267case 103:268break;269case 116:270break;271default:272iFld >>= 1;273}274}275}276return iFld;277}278279public int test8() {280281iFld = 13;282for (int i = 0; i < 8; i++) {283int j = 50;284while (--j > 0) {285// All statements before the switch expression are partially peeled286iFld += -7;287x = y + iFld;288y = iArr[5];289iArr[5] = 5;290iArr[6] += 23;291iArr[7] = iArr[8] + iArr[6];292switch ((val * 5) + 102) {293case 120:294break;295case 103:296break;297case 116:298break;299default:300iFld >>= 1;301}302}303}304return iFld;305}306307308public int test9() {309iFld = 13;310for (int i = 0; i < 8; i++) {311int j = 10;312while (--j > 0) {313iFld += -7;314iArr[4] = 8;315x = iArr[5];316switch ((i * 5) + 102) {317case 120:318return iFld + 1;319case 103:320break;321case 116:322break;323default:324iFld >>= 1;325}326}327}328329return iFld;330}331332public int test10() {333if (z < 34) {334z = 34;335}336337iFld = 13;338for (int i = 0; i < 80; i++) {339int j = 50;340while (--j > 0) {341iFld += -7;342iArr[4] = 8;343x = iArr[5];344switch ((i * 5) + 102) {345case 120:346break;347case 103:348break;349case 116:350break;351default:352iFld >>= 1;353}354}355}356if (z == 34) {357x = iArr[6];358}359return iFld;360}361362363public int test11Xcomp() {364if (z < 34) {365z = 34;366}367368iFld = 13;369for (int i = 0; i < 80; i++) {370int j = 50;371while (--j > 0) {372iFld += -7;373iArr[4] = 8;374x = iArr[5];375switch ((i * 5) + 102) {376case 120:377break;378case 103:379break;380case 116:381break;382default:383iFld >>= 1;384}385if (z == 34) {386break;387}388}389}390if (z == 34) {391x = iArr[6];392}393return iFld;394}395396// Phi with multiple inputs from same peeled node397public int test12Xcomp() {398if (z < 34) {399z = 34;400}401402iFld = 13;403for (int i = 0; i < 80; i++) {404int j = 50;405while (--j > 0) {406iFld += -7;407iArr[4] = 8;408x = iArr[5];409switch ((i * 5) + 102) {410case 120:411break;412case 103:413break;414case 116:415return z;416case 106:417return y;418case 111:419return x;420default:421iFld >>= 1;422}423w = 45;424}425426}427if (z == 34) {428x = iArr[6];429}430return iFld;431}432433public int test13Xcomp() {434if (z < 34) {435z = 34;436}437438iFld = 13;439for (int i = 0; i < 80; i++) {440int j = 50;441while (--j > 0) {442iFld += -7;443iArr[4] = 8;444x = iArr[5];445switch ((i * 5) + 102) {446case 120:447break;448case 103:449break;450case 116:451break;452default:453iFld >>= 1;454}455w = 45;456}457458}459if (z == 34) {460x = iArr[6];461}462return iFld;463}464465// Triggers after peeling with Xcomp466public int test14Peel() {467iFld = 13;468for (int i = 0; i < 8; i++) {469int j = 10;470while (--j > 0) {471iFld += -7;472iArr[4] = 8;473x = iArr[5];474switch ((i * 5) + 102) {475case 120:476return iFld;477case 103:478break;479case 116:480break;481default:482iFld >>= 1;483}484iFld = 3;485}486}487y = iArr[4];488x = iArr[6];489490return iFld;491}492493494public int test15earlyCtrl() {495iFld = 13;496if (z < 34) {497z = 34;498}499500for (int i = 0; i < 8; i++) {501int j = 10;502while (--j > 0) {503iFld += -7;504iArr[5] = 8;505x = iArr[6];506y = x;507x = iArr[7];508switch ((i * 5) + 102) {509case 120:510return iFld;511case 103:512break;513case 116:514break;515default:516if (iFld == -7) {517return iFld;518}519z = iArr[5];520iFld >>= 1;521}522}523if (iFld == 7) {524iArr[3] = 3;525}526dontInline(7);527iArr[5] = 34;528}529return iFld;530}531532// Load after loop -> LoadI after loop from peeled StoreI533public int test16() {534iFld = 13;535if (z < 34) {536z = 34;537}538539for (int i = 0; i < 8; i++) {540int j = 60;541while (--j > 0) {542iFld += -7;543y += iFld + 1;544545iArr[5] = 8;546x = iArr[6];547x = iArr[7];548switch ((i * 5) + 102) {549case 120:550return iFld;551case 103:552break;553case 116:554break;555default:556if (iFld == -7) {557return iFld;558}559z = iArr[5];560iFld >>= 1;561}562}563w = iArr[9];564if (iFld == 7) {565iArr[3] = 3;566}567dontInline(7);568iArr[5] = 34;569}570return iFld;571}572573// Region 13 before return, which region to choose for MergeMem?574public int test17Xcomp() {575A p = dontInlineGetA();576if (z < 34) {577z = 34;578}579580iFld = 13;581for (int i = 0; i < 80; i++) {582int j = 50;583while (--j > 0) {584iFld += -7;585iArr[4] = 8;586x = iArr[5];587y = p.i;588switch ((i * 5) + 102) {589case 120:590break;591case 103:592break;593case 116:594return z;595case 106:596return y;597case 111:598return x;599default:600iFld >>= 1;601}602w = 45;603}604605}606if (z == 34) {607x = iArr[6];608}609return iFld;610}611612// Region 13 before return, which region to choose for MergeMem?613public int test18Xcomp() {614if (z < 34) {615z = 34;616}617618iFld = 13;619for (int i = 0; i < 80; i++) {620int j = 50;621while (--j > 0) {622iFld += -7;623iArr[4] = 8;624x = iArr[5];625y = 85;626switch ((i * 5) + 102) {627case 120:628break;629case 103:630break;631case 116:632return z;633case 106:634if (z == 34) {635x = iArr[7];636}637return y;638case 111:639return x;640default:641iFld >>= 1;642}643w = 45;644}645646}647648if (z == 34) {649x = iArr[6];650}651return iFld;652}653654public int test19Xcomp() {655if (z < 34) {656z = 34;657}658659iFld = 13;660for (int i = 0; i < 80; i++) {661int j = 50;662while (--j > 0) {663iFld += -7;664iArr[4] = 8;665x = iArr[5]+ iArr[6];666y = 85;667switch ((i * 5) + 102) {668case 120:669break;670case 103:671break;672case 116:673break;674case 106:675if (z == 34) {676x = iArr[7];677}678return y;679case 111:680return x;681default:682iFld >>= 1;683}684w = 45;685}686}687688if (z == 34) {689iArr[7] = 34;690}691return iFld;692}693694public int test20() {695if (z < 34) {696z = 34;697}698699iFld = 13;700for (int i = 0; i < 80; i++) {701int j = 50;702while (--j > 0) {703iFld += -7;704iArr[4] = 8;705x = iArr[5];706switch ((i * 5) + 102) {707case 120:708break;709case 103:710break;711case 116:712break;713default:714iFld >>= 1;715}716}717x = iArr[6];718}719if (z == 34) {720x = iArr[7];721}722return iFld;723}724725726public int test21() {727if (z < 34) {728z = 34;729}730731iFld = 13;732for (int i = 0; i < 80; i++) {733int j = 50;734while (--j > 0) {735iFld += -7;736iArr[4] = 8;737x = iArr[5];738switch ((i * 5) + 102) {739case 120:740break;741case 103:742break;743case 116:744break;745default:746iFld >>= 1;747}748}749x = iArr[6];750}751if (z == 34) {752y = iArr[7];753}754return iFld;755}756757public int testNoOuter() {758iFld = 13;759int j = 10;760while (--j > 0) {761iFld += -7;762switch ((iCon * 5) + 102) {763case 120:764break;765case 103:766break;767case 116:768break;769default:770iFld >>= 1;771}772}773return iFld;774}775776public int test2NoOuter() {777/*778* Same nested loop structure as in test() but with more statements that are partially peeled from the inner loop.779* Afterwards the inner loop is unswitched.780*/781iFld = 13;782int k = 0;783int j = 10;784while (--j > 0) {785// All statements before the switch expression are partially peeled786iFld += -7;787x = y + iFld;788y = iArr[5];789k = 6;790iArr[5] = 5;791iArr[6] += 23;792iArr[7] = iArr[8] + iArr[6];793iArr[j] = 34;794switch ((iCon * 5) + 102) {795case 120:796break;797case 103:798break;799case 116:800break;801default:802iFld >>= 1;803}804}805return iFld + k;806}807808public int test3NoOuter() {809iFld = 13;810if (z < 34) {811z = 34;812}813814int j = 10;815while (--j > 0) {816iFld += -7;817iArr[5] = 8;818x = iArr[6];819y = x;820for (int k = 50; k < 51; k++) {821x = iArr[7];822}823switch ((iCon * 5) + 102) {824case 120:825return iFld;826case 103:827break;828case 116:829break;830default:831if (iFld == -7) {832return iFld;833}834z = iArr[5];835iFld >>= 1;836}837}838iArr[5] = 34;839dontInline(iArr[5]);840return iFld;841}842843public int test4NoOuter() {844iFld = 13;845if (z < 34) {846z = 34;847}848849int j = 10;850while (--j > 0) {851iFld += -7;852iArr[5] = 8;853x = iArr[6];854y = x;855for (int k = 50; k < 51; k++) {856x = iArr[7];857}858switch ((iCon * 5) + 102) {859case 120:860return iFld;861case 103:862break;863case 116:864break;865default:866if (iFld == -7) {867return iFld;868}869z = iArr[5];870iFld >>= 1;871}872}873iArr[5] = 34;874return iFld;875}876877public int test5NoOuter() {878iFld = 13;879int j = 10;880while (--j > 0) {881iFld += -7;882iArr[5] = 8;883x = iArr[6];884y = x;885for (int k = 50; k < 51; k++) {886x = iArr[7];887}888switch ((iCon * 5) + 102) {889case 120:890return iFld;891case 103:892break;893case 116:894break;895default:896iFld >>= 1;897}898}899return iFld;900}901902public int test6NoOuter() {903iFld = 13;904int j = 10;905while (--j > 0) {906iFld += -7;907iArr[5] = 8;908x = iArr[6];909y = x;910switch ((iCon * 5) + 102) {911case 120:912return iFld;913case 103:914break;915case 116:916break;917default:918iFld >>= 1;919}920}921return iFld;922}923924public int test7NoOuter() {925iFld = 13;926int j = 10;927while (--j > 0) {928iFld += -7;929iArr[5] = 8;930switch ((iCon * 5) + 102) {931case 120:932return iFld;933case 103:934break;935case 116:936break;937default:938iFld >>= 1;939}940}941return iFld;942}943944public int test8NoOuter() {945946iFld = 13;947int j = 50;948while (--j > 0) {949// All statements before the switch expression are partially peeled950iFld += -7;951x = y + iFld;952y = iArr[5];953iArr[5] = 5;954iArr[6] += 23;955iArr[7] = iArr[8] + iArr[6];956switch ((val * 5) + 102) {957case 120:958break;959case 103:960break;961case 116:962break;963default:964iFld >>= 1;965}966}967return iFld;968}969970971public int test9NoOuter() {972iFld = 13;973int j = 10;974while (--j > 0) {975iFld += -7;976iArr[4] = 8;977x = iArr[5];978switch ((iCon * 5) + 102) {979case 120:980return iFld + 1;981case 103:982break;983case 116:984break;985default:986iFld >>= 1;987}988}989return iFld;990}991992public int test10NoOuter() {993if (z < 34) {994z = 34;995}996997iFld = 13;998int j = 50;999while (--j > 0) {1000iFld += -7;1001iArr[4] = 8;1002x = iArr[5];1003switch ((iCon * 5) + 102) {1004case 120:1005break;1006case 103:1007break;1008case 116:1009break;1010default:1011iFld >>= 1;1012}1013}1014if (z == 34) {1015x = iArr[6];1016}1017return iFld;1018}101910201021public int test11XcompNoOuter() {1022if (z < 34) {1023z = 34;1024}10251026iFld = 13;1027int j = 50;1028while (--j > 0) {1029iFld += -7;1030iArr[4] = 8;1031x = iArr[5];1032switch ((iCon * 5) + 102) {1033case 120:1034break;1035case 103:1036break;1037case 116:1038break;1039default:1040iFld >>= 1;1041}1042if (z == 34) {1043break;1044}1045}1046if (z == 34) {1047x = iArr[6];1048}1049return iFld;1050}10511052// Phi with multiple inputs from same peeled node1053public int test12XcompNoOuter() {1054if (z < 34) {1055z = 34;1056}10571058iFld = 13;1059int j = 50;1060while (--j > 0) {1061iFld += -7;1062iArr[4] = 8;1063x = iArr[5];1064switch ((iCon * 5) + 102) {1065case 120:1066break;1067case 103:1068break;1069case 116:1070return z;1071case 106:1072return y;1073case 111:1074return x;1075default:1076iFld >>= 1;1077}1078w = 45;1079}10801081if (z == 34) {1082x = iArr[6];1083}1084return iFld;1085}10861087public int test13XcompNoOuter() {1088if (z < 34) {1089z = 34;1090}10911092iFld = 13;1093int j = 50;1094while (--j > 0) {1095iFld += -7;1096iArr[4] = 8;1097x = iArr[5];1098switch ((iCon * 5) + 102) {1099case 120:1100break;1101case 103:1102break;1103case 116:1104break;1105default:1106iFld >>= 1;1107}1108w = 45;1109}11101111if (z == 34) {1112x = iArr[6];1113}1114return iFld;1115}11161117// Triggers after peeling with Xcomp1118public int test14PeelNoOuter() {1119iFld = 13;1120int j = 10;1121while (--j > 0) {1122iFld += -7;1123iArr[4] = 8;1124x = iArr[5];1125switch ((iCon * 5) + 102) {1126case 120:1127return iFld;1128case 103:1129break;1130case 116:1131break;1132default:1133iFld >>= 1;1134}1135iFld = 3;1136}1137y = iArr[4];1138x = iArr[6];11391140return iFld;1141}114211431144public int test15earlyCtrlNoOuter() {1145iFld = 13;1146if (z < 34) {1147z = 34;1148}11491150int j = 10;1151while (--j > 0) {1152iFld += -7;1153iArr[5] = 8;1154x = iArr[6];1155y = x;1156x = iArr[7];1157switch ((iCon * 5) + 102) {1158case 120:1159return iFld;1160case 103:1161break;1162case 116:1163break;1164default:1165if (iFld == -7) {1166return iFld;1167}1168z = iArr[5];1169iFld >>= 1;1170}1171}1172if (iFld == 7) {1173iArr[3] = 3;1174}1175dontInline(7);1176iArr[5] = 34;1177return iFld;1178}11791180// Load after loop -> LoadI after loop from peeled StoreI1181public int test16NoOuter() {1182iFld = 13;1183if (z < 34) {1184z = 34;1185}11861187int j = 60;1188while (--j > 0) {1189iFld += -7;1190y += iFld + 1;11911192iArr[5] = 8;1193x = iArr[6];1194x = iArr[7];1195switch ((iCon * 5) + 102) {1196case 120:1197return iFld;1198case 103:1199break;1200case 116:1201break;1202default:1203if (iFld == -7) {1204return iFld;1205}1206z = iArr[5];1207iFld >>= 1;1208}1209}1210w = iArr[9];1211if (iFld == 7) {1212iArr[3] = 3;1213}1214dontInline(7);1215iArr[5] = 34;1216return iFld;1217}12181219// Region 13 before return, which region to choose for MergeMem?1220public int test17XcompNoOuter() {1221A p = dontInlineGetA();1222if (z < 34) {1223z = 34;1224}12251226iFld = 13;1227int j = 50;1228while (--j > 0) {1229iFld += -7;1230iArr[4] = 8;1231x = iArr[5];1232y = p.i;1233switch ((iCon * 5) + 102) {1234case 120:1235break;1236case 103:1237break;1238case 116:1239return z;1240case 106:1241return y;1242case 111:1243return x;1244default:1245iFld >>= 1;1246}1247w = 45;1248}1249if (z == 34) {1250x = iArr[6];1251}1252return iFld;1253}12541255// Region 13 before return, which region to choose for MergeMem?1256public int test18XcompNoOuter() {1257if (z < 34) {1258z = 34;1259}12601261iFld = 13;1262int j = 50;1263while (--j > 0) {1264iFld += -7;1265iArr[4] = 8;1266x = iArr[5];1267y = 85;1268switch ((iCon * 5) + 102) {1269case 120:1270break;1271case 103:1272break;1273case 116:1274return z;1275case 106:1276if (z == 34) {1277x = iArr[7];1278}1279return y;1280case 111:1281return x;1282default:1283iFld >>= 1;1284}1285w = 45;1286}12871288if (z == 34) {1289x = iArr[6];1290}1291return iFld;1292}12931294public int test19XcompNoOuter() {1295if (z < 34) {1296z = 34;1297}12981299iFld = 13;1300int j = 50;1301while (--j > 0) {1302iFld += -7;1303iArr[4] = 8;1304x = iArr[5]+ iArr[6];1305y = 85;1306switch ((iCon * 5) + 102) {1307case 120:1308break;1309case 103:1310break;1311case 116:1312break;1313case 106:1314if (z == 34) {1315x = iArr[7];1316}1317return y;1318case 111:1319return x;1320default:1321iFld >>= 1;1322}1323w = 45;1324}13251326if (z == 34) {1327iArr[7] = 34;1328}1329return iFld;1330}133113321333public int test20NoOuter() {1334if (z < 34) {1335z = 34;1336}13371338iFld = 13;1339int j = 50;1340while (--j > 0) {1341iFld += -7;1342iArr[4] = 8;1343x = iArr[5];1344switch ((iCon * 5) + 102) {1345case 120:1346break;1347case 103:1348break;1349case 116:1350break;1351default:1352iFld >>= 1;1353}1354}1355x = iArr[6];1356if (z == 34) {1357x = iArr[7];1358}1359return iFld;1360}13611362public int test21NoOuter() {1363if (z < 34) {1364z = 34;1365}13661367iFld = 13;1368int j = 50;1369while (--j > 0) {1370iFld += -7;1371iArr[4] = 8;1372x = iArr[5];1373switch ((iCon * 5) + 102) {1374case 120:1375break;1376case 103:1377break;1378case 116:1379break;1380default:1381iFld >>= 1;1382}1383}1384x = iArr[6];1385if (z == 34) {1386y = iArr[7];1387}1388return iFld;1389}1390public static void main(String[] strArr) {1391BookKeeper[] bookKeeper = new BookKeeper[22];1392for (int i = 0; i < 22; i++) {1393bookKeeper[i] = new BookKeeper();1394}13951396PartialPeelingUnswitch _instance = new PartialPeelingUnswitch();1397for (int i = 0; i < 2000; i++) {1398int result = _instance.test();1399if (result != -7) {1400throw new RuntimeException("Result should always be -7 but was " + result);1401}1402}14031404for (int i = 0; i < 2000; i++) {1405int result = _instance.test2();1406check(-1, result);1407check(-7, iFld);1408check(-9, x);1409check(5, y);1410check(5, iArr[5]);1411check(149, iArr[6]);1412check(183, iArr[7]);14131414// Reset fields1415for (int j = 0; j < 10; j++) {1416iArr[j] = 0;1417}1418x = 42;1419y = 31;1420}14211422for (int i = 0; i < 2000; i++) {1423BookKeeper.setup();1424_instance.test3();1425bookKeeper[3].compare();1426BookKeeper.setup();1427_instance.test4();1428bookKeeper[4].compare();1429BookKeeper.setup();1430_instance.test5();1431bookKeeper[5].compare();1432BookKeeper.setup();1433_instance.test6();1434bookKeeper[6].compare();1435BookKeeper.setup();1436_instance.test7();1437bookKeeper[7].compare();1438BookKeeper.setup();1439_instance.test8();1440bookKeeper[8].compare();1441BookKeeper.setup();1442_instance.test9();1443bookKeeper[9].compare();1444BookKeeper.setup();1445_instance.test10();1446bookKeeper[10].compare();1447BookKeeper.setup();1448_instance.test11Xcomp();1449bookKeeper[11].compare();1450BookKeeper.setup();1451_instance.test12Xcomp();1452bookKeeper[12].compare();1453BookKeeper.setup();1454_instance.test13Xcomp();1455bookKeeper[13].compare();1456BookKeeper.setup();1457_instance.test14Peel();1458bookKeeper[14].compare();1459BookKeeper.setup();1460_instance.test15earlyCtrl();1461bookKeeper[15].compare();1462BookKeeper.setup();1463_instance.test16();1464bookKeeper[16].compare();1465BookKeeper.setup();1466_instance.test17Xcomp();1467bookKeeper[17].compare();1468BookKeeper.setup();1469_instance.test18Xcomp();1470bookKeeper[18].compare();1471BookKeeper.setup();1472_instance.test19Xcomp();1473bookKeeper[19].compare();1474BookKeeper.setup();1475_instance.test20();1476bookKeeper[20].compare();1477BookKeeper.setup();1478_instance.test21();1479bookKeeper[21].compare();1480}14811482for (int i = 0; i < 22; i++) {1483bookKeeper[i] = new BookKeeper();1484}14851486for (int i = 0; i < 2000; i++) {1487BookKeeper.setup();1488_instance.testNoOuter();1489bookKeeper[1].compare();1490BookKeeper.setup();1491_instance.test2NoOuter();1492bookKeeper[2].compare();1493BookKeeper.setup();1494_instance.test3NoOuter();1495bookKeeper[3].compare();1496BookKeeper.setup();1497_instance.test4NoOuter();1498bookKeeper[4].compare();1499BookKeeper.setup();1500_instance.test5NoOuter();1501bookKeeper[5].compare();1502BookKeeper.setup();1503_instance.test6NoOuter();1504bookKeeper[6].compare();1505BookKeeper.setup();1506_instance.test7NoOuter();1507bookKeeper[7].compare();1508BookKeeper.setup();1509_instance.test8NoOuter();1510bookKeeper[8].compare();1511BookKeeper.setup();1512_instance.test9NoOuter();1513bookKeeper[9].compare();1514BookKeeper.setup();1515_instance.test10NoOuter();1516bookKeeper[10].compare();1517BookKeeper.setup();1518_instance.test11XcompNoOuter();1519bookKeeper[11].compare();1520BookKeeper.setup();1521_instance.test12XcompNoOuter();1522bookKeeper[12].compare();1523BookKeeper.setup();1524_instance.test13XcompNoOuter();1525bookKeeper[13].compare();1526BookKeeper.setup();1527_instance.test14PeelNoOuter();1528bookKeeper[14].compare();1529BookKeeper.setup();1530_instance.test15earlyCtrlNoOuter();1531bookKeeper[15].compare();1532BookKeeper.setup();1533_instance.test16NoOuter();1534bookKeeper[16].compare();1535BookKeeper.setup();1536_instance.test17XcompNoOuter();1537bookKeeper[17].compare();1538BookKeeper.setup();1539_instance.test18XcompNoOuter();1540bookKeeper[18].compare();1541BookKeeper.setup();1542_instance.test19XcompNoOuter();1543bookKeeper[19].compare();1544BookKeeper.setup();1545_instance.test20NoOuter();1546bookKeeper[20].compare();1547BookKeeper.setup();1548_instance.test21NoOuter();1549bookKeeper[21].compare();1550}15511552for (int i = 0; i < 22; i++) {1553bookKeeper[i] = new BookKeeper();1554}15551556for (int i = 0; i < 2000; i++) {1557BookKeeper.setup();1558setZ(i);1559_instance.test3();1560bookKeeper[3].compare(i);1561BookKeeper.setup();1562setZ(i);1563_instance.test4();1564bookKeeper[4].compare(i);1565BookKeeper.setup();1566setZ(i);1567_instance.test5();1568bookKeeper[5].compare(i);1569BookKeeper.setup();1570setZ(i);1571_instance.test6();1572bookKeeper[6].compare(i);1573BookKeeper.setup();1574setZ(i);1575_instance.test7();1576bookKeeper[7].compare(i);1577BookKeeper.setup();1578setZ(i);1579_instance.test8();1580bookKeeper[8].compare(i);1581BookKeeper.setup();1582setZ(i);1583_instance.test9();1584bookKeeper[9].compare(i);1585BookKeeper.setup();1586setZ(i);1587_instance.test10();1588bookKeeper[10].compare(i);1589setZ(i);1590BookKeeper.setup();1591_instance.test11Xcomp();1592bookKeeper[11].compare(i);1593setZ(i);1594BookKeeper.setup();1595_instance.test12Xcomp();1596bookKeeper[12].compare(i);1597setZ(i);1598BookKeeper.setup();1599_instance.test13Xcomp();1600bookKeeper[13].compare(i);1601setZ(i);1602BookKeeper.setup();1603_instance.test14Peel();1604bookKeeper[14].compare(i);1605setZ(i);1606BookKeeper.setup();1607_instance.test15earlyCtrl();1608bookKeeper[15].compare(i);1609setZ(i);1610BookKeeper.setup();1611_instance.test16();1612bookKeeper[16].compare(i);1613setZ(i);1614BookKeeper.setup();1615_instance.test17Xcomp();1616bookKeeper[17].compare(i);1617setZ(i);1618BookKeeper.setup();1619_instance.test18Xcomp();1620bookKeeper[18].compare(i);1621setZ(i);1622BookKeeper.setup();1623_instance.test19Xcomp();1624bookKeeper[19].compare(i);1625setZ(i);1626BookKeeper.setup();1627_instance.test20();1628bookKeeper[20].compare(i);1629setZ(i);1630BookKeeper.setup();1631_instance.test21();1632bookKeeper[21].compare(i);1633}16341635for (int i = 0; i < 22; i++) {1636bookKeeper[i] = new BookKeeper();1637}16381639for (int i = 0; i < 2000; i++) {1640BookKeeper.setup();1641setZ(i);1642_instance.testNoOuter();1643bookKeeper[1].compare(i);1644BookKeeper.setup();1645setZ(i);1646_instance.test2NoOuter();1647bookKeeper[2].compare(i);1648BookKeeper.setup();1649setZ(i);1650_instance.test3NoOuter();1651bookKeeper[3].compare(i);1652BookKeeper.setup();1653setZ(i);1654_instance.test4NoOuter();1655bookKeeper[4].compare(i);1656BookKeeper.setup();1657setZ(i);1658_instance.test5NoOuter();1659bookKeeper[5].compare(i);1660BookKeeper.setup();1661setZ(i);1662_instance.test6NoOuter();1663bookKeeper[6].compare(i);1664BookKeeper.setup();1665setZ(i);1666_instance.test7NoOuter();1667bookKeeper[7].compare(i);1668BookKeeper.setup();1669setZ(i);1670_instance.test8NoOuter();1671bookKeeper[8].compare(i);1672BookKeeper.setup();1673setZ(i);1674_instance.test9NoOuter();1675bookKeeper[9].compare(i);1676BookKeeper.setup();1677setZ(i);1678_instance.test10NoOuter();1679bookKeeper[10].compare(i);1680BookKeeper.setup();1681setZ(i);1682_instance.test11XcompNoOuter();1683bookKeeper[11].compare(i);1684BookKeeper.setup();1685setZ(i);1686_instance.test12XcompNoOuter();1687bookKeeper[12].compare(i);1688BookKeeper.setup();1689setZ(i);1690_instance.test13XcompNoOuter();1691bookKeeper[13].compare(i);1692BookKeeper.setup();1693setZ(i);1694_instance.test14PeelNoOuter();1695bookKeeper[14].compare(i);1696BookKeeper.setup();1697setZ(i);1698_instance.test15earlyCtrlNoOuter();1699bookKeeper[15].compare(i);1700BookKeeper.setup();1701setZ(i);1702_instance.test16NoOuter();1703bookKeeper[16].compare(i);1704BookKeeper.setup();1705setZ(i);1706_instance.test17XcompNoOuter();1707bookKeeper[17].compare(i);1708BookKeeper.setup();1709setZ(i);1710_instance.test18XcompNoOuter();1711bookKeeper[18].compare(i);1712BookKeeper.setup();1713setZ(i);1714_instance.test19XcompNoOuter();1715bookKeeper[19].compare(i);1716BookKeeper.setup();1717setZ(i);1718_instance.test20NoOuter();1719bookKeeper[20].compare(i);1720BookKeeper.setup();1721setZ(i);1722_instance.test21NoOuter();1723bookKeeper[21].compare(i);1724}1725}17261727public static void setZ(int i) {1728if (i % 2 == 0) {1729z = 23;1730} else {1731z = 35;1732}1733}17341735public static void check(int expected, int actual) {1736if (expected != actual) {1737throw new RuntimeException("Wrong result, expected: " + expected + ", actual: " + actual);1738}1739}17401741public void dontInline(int i) { }17421743class A {1744int i = 3;1745}17461747A dontInlineGetA() {1748return new A();1749}17501751static class BookKeeper {1752public int iFld;1753public int w;1754public int x;1755public int y;1756public int z;1757public int val;1758public int[] iArr;17591760public int iFld2;1761public int w2;1762public int x2;1763public int y2;1764public int z2;1765public int val2;1766public int[] iArr2;17671768public void compare() {1769if (iArr == null) {1770// First compare, initialize values1771this.iFld = PartialPeelingUnswitch.iFld;1772this.w = PartialPeelingUnswitch.w;1773this.x = PartialPeelingUnswitch.x;1774this.y = PartialPeelingUnswitch.y;1775this.z = PartialPeelingUnswitch.z;1776this.val = PartialPeelingUnswitch.val;1777this.iArr = new int[10];1778System.arraycopy(PartialPeelingUnswitch.iArr, 0, this.iArr, 0, 10);1779} else {17801781// Do comparison1782boolean check = PartialPeelingUnswitch.iFld == this.iFld1783&& this.w == PartialPeelingUnswitch.w1784&& this.x == PartialPeelingUnswitch.x1785&& this.y == PartialPeelingUnswitch.y1786&& this.z == PartialPeelingUnswitch.z1787&& this.val == PartialPeelingUnswitch.val;1788for (int i = 0; i < 10; i++) {1789check = check && this.iArr[i] == PartialPeelingUnswitch.iArr[i];1790}17911792if (!check) {1793throw new RuntimeException("Failed comparison");1794}1795}1796}17971798public void compare(int i) {1799if (i % 2 == 0 && iArr == null) {1800// First compare, initialize values1801this.iFld = PartialPeelingUnswitch.iFld;1802this.w = PartialPeelingUnswitch.w;1803this.x = PartialPeelingUnswitch.x;1804this.y = PartialPeelingUnswitch.y;1805this.z = PartialPeelingUnswitch.z;1806this.val = PartialPeelingUnswitch.val;1807this.iArr = new int[10];1808System.arraycopy(PartialPeelingUnswitch.iArr, 0, this.iArr, 0, 10);1809} else if (i % 2 != 0 && iArr2 == null) {1810// First compare, initialize values1811this.iFld2 = PartialPeelingUnswitch.iFld;1812this.w2 = PartialPeelingUnswitch.w;1813this.x2 = PartialPeelingUnswitch.x;1814this.y2 = PartialPeelingUnswitch.y;1815this.z2 = PartialPeelingUnswitch.z;1816this.val2 = PartialPeelingUnswitch.val;1817this.iArr2 = new int[10];1818System.arraycopy(PartialPeelingUnswitch.iArr, 0, this.iArr2, 0, 10);1819} else if (i % 2 == 0) {1820// Do comparison1821boolean check = PartialPeelingUnswitch.iFld == this.iFld1822&& this.w == PartialPeelingUnswitch.w1823&& this.x == PartialPeelingUnswitch.x1824&& this.y == PartialPeelingUnswitch.y1825&& this.z == PartialPeelingUnswitch.z1826&& this.val == PartialPeelingUnswitch.val;1827for (int j = 0; j < 10; j++) {1828check = check && this.iArr[j] == PartialPeelingUnswitch.iArr[j];1829}18301831if (!check) {1832throw new RuntimeException("Failed comparison");1833}1834} else {1835// Do comparison1836boolean check = PartialPeelingUnswitch.iFld == this.iFld21837&& this.w2 == PartialPeelingUnswitch.w1838&& this.x2 == PartialPeelingUnswitch.x1839&& this.y2 == PartialPeelingUnswitch.y1840&& this.z2 == PartialPeelingUnswitch.z1841&& this.val2 == PartialPeelingUnswitch.val;1842for (int j = 0; j < 10; j++) {1843check = check && this.iArr2[j] == PartialPeelingUnswitch.iArr[j];1844}18451846if (!check) {1847throw new RuntimeException("Failed comparison");1848}1849}1850}18511852public static void setup() {1853PartialPeelingUnswitch.iFld = 0;1854PartialPeelingUnswitch.w = 88;1855PartialPeelingUnswitch.x = 42;1856PartialPeelingUnswitch.y = 31;1857PartialPeelingUnswitch.z = 22;1858PartialPeelingUnswitch.val = 34;1859PartialPeelingUnswitch.iArr = new int[10];1860}1861}1862}186318641865