1 /*
   2  * Copyright (c) 2010, 2018, 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 6909839
  27  * @summary missing unsigned compare cases for some cmoves in sparc.ad
  28  *
  29  * @run main/othervm -XX:+EliminateAutoBox -XX:AutoBoxCacheMax=20000 -Xbatch compiler.codegen.Test6909839
  30  */
  31 
  32 package compiler.codegen;
  33 
  34 public class Test6909839 {
  35     public static void main(String[] args) {
  36         testi();
  37         testi();
  38         testi();
  39         testui();
  40         testui();
  41         testui();
  42         testdi();
  43         testdi();
  44         testdi();
  45         testfi();
  46         testfi();
  47         testfi();
  48 
  49         testl();
  50         testl();
  51         testl();
  52         testul();
  53         testul();
  54         testul();
  55         testdl();
  56         testdl();
  57         testdl();
  58         testfl();
  59         testfl();
  60         testfl();
  61 
  62         testf();
  63         testf();
  64         testf();
  65         testuf();
  66         testuf();
  67         testuf();
  68         testdf();
  69         testdf();
  70         testdf();
  71         testff();
  72         testff();
  73         testff();
  74 
  75         testd();
  76         testd();
  77         testd();
  78         testud();
  79         testud();
  80         testud();
  81         testdd();
  82         testdd();
  83         testdd();
  84         testfd();
  85         testfd();
  86         testfd();
  87 
  88         testp();
  89         testp();
  90         testp();
  91         testup();
  92         testup();
  93         testup();
  94         testdp();
  95         testdp();
  96         testdp();
  97         testfp();
  98         testfp();
  99         testfp();
 100     }
 101 
 102     static void testui() {
 103         int total = 0;
 104         for (int i = 0 ; i < 10000; i++) {
 105             int v = i % 4;
 106             total += ((v >= 1 && v < 3) ? 1 : 2);
 107         }
 108         System.out.println(total);
 109     }
 110 
 111     static void testdi() {
 112         int total = 0;
 113         for (int i = 0 ; i < 10000; i++) {
 114             int v = i % 4;
 115             total += (v > 1.0) ? 1 : 2;
 116         }
 117         System.out.println(total);
 118     }
 119 
 120     static void testfi() {
 121         int total = 0;
 122         for (int i = 0 ; i < 10000; i++) {
 123             int v = i % 4;
 124             total += (v > 1.0f) ? 1 : 2;
 125         }
 126         System.out.println(total);
 127     }
 128 
 129     static void testi() {
 130         int total = 0;
 131         for (int i = 0 ; i < 10000; i++) {
 132             total += (i % 4 != 0) ? 1 : 2;
 133         }
 134         System.out.println(total);
 135     }
 136 
 137     static void testul() {
 138         long total = 0;
 139         for (int i = 0 ; i < 10000; i++) {
 140             int v = i % 4;
 141             total += ((v >= 1 && v < 3) ? 1L : 2L);
 142         }
 143         System.out.println(total);
 144     }
 145 
 146     static void testdl() {
 147         long total = 0;
 148         for (int i = 0 ; i < 10000; i++) {
 149             int v = i % 4;
 150             total += (v > 1.0) ? 1L : 2L;
 151         }
 152         System.out.println(total);
 153     }
 154 
 155     static void testfl() {
 156         long total = 0;
 157         for (int i = 0 ; i < 10000; i++) {
 158             int v = i % 4;
 159             total += (v > 1.0f) ? 1L : 2L;
 160         }
 161         System.out.println(total);
 162     }
 163 
 164     static void testl() {
 165         long total = 0;
 166         for (int i = 0 ; i < 10000; i++) {
 167             total += (i % 4 != 0) ? 1L : 2L;
 168         }
 169         System.out.println(total);
 170     }
 171 
 172     static void testuf() {
 173         float total = 0;
 174         for (int i = 0 ; i < 10000; i++) {
 175             int v = i % 4;
 176             total += ((v >= 1 && v < 3) ? 1.0f : 2.0f);
 177         }
 178         System.out.println(total);
 179     }
 180 
 181     static void testdf() {
 182         float total = 0;
 183         for (int i = 0 ; i < 10000; i++) {
 184             int v = i % 4;
 185             total += (v > 0.0) ? 1.0f : 2.0f;
 186         }
 187         System.out.println(total);
 188     }
 189 
 190     static void testff() {
 191         float total = 0;
 192         for (int i = 0 ; i < 10000; i++) {
 193             int v = i % 4;
 194             total += (v > 0.0f) ? 1.0f : 2.0f;
 195         }
 196         System.out.println(total);
 197     }
 198 
 199     static void testf() {
 200         float total = 0;
 201         for (int i = 0 ; i < 10000; i++) {
 202             total += (i % 4 != 0) ? 1.0f : 2.0f;
 203         }
 204         System.out.println(total);
 205     }
 206 
 207     static void testud() {
 208         double total = 0;
 209         for (int i = 0 ; i < 10000; i++) {
 210             int v = i % 4;
 211             total += ((v >= 1 && v < 3) ? 1.0d : 2.0d);
 212         }
 213         System.out.println(total);
 214     }
 215 
 216     static void testdd() {
 217         double total = 0;
 218         for (int i = 0 ; i < 10000; i++) {
 219             int v = i % 4;
 220             total += (v > 1.0) ? 1.0d : 2.0d;
 221         }
 222         System.out.println(total);
 223     }
 224 
 225     static void testfd() {
 226         double total = 0;
 227         for (int i = 0 ; i < 10000; i++) {
 228             int v = i % 4;
 229             total += (v > 1.0f) ? 1.0d : 2.0d;
 230         }
 231         System.out.println(total);
 232     }
 233 
 234     static void testd() {
 235         double total = 0;
 236         for (int i = 0 ; i < 10000; i++) {
 237             total += (i % 4 != 0) ? 1.0d : 2.0d;
 238         }
 239         System.out.println(total);
 240     }
 241 
 242     static void testp() {
 243         Object a = new Object();
 244         Object b = new Object();;
 245         int total = 0;
 246         for (int i = 0 ; i < 10000; i++) {
 247             total += ((i % 4 != 0) ? a : b).hashCode();
 248         }
 249         System.out.println(total);
 250     }
 251 
 252     static void testup() {
 253         Object a = new Object();
 254         Object b = new Object();;
 255         int total = 0;
 256         for (int i = 0 ; i < 10000; i++) {
 257             int v = i % 4;
 258             total += ((v >= 1 && v < 3) ? a : b).hashCode();
 259         }
 260         System.out.println(total);
 261     }
 262 
 263     static void testdp() {
 264         Object a = new Object();
 265         Object b = new Object();;
 266         int total = 0;
 267         for (int i = 0 ; i < 10000; i++) {
 268             int v = i % 4;
 269             total += ((v > 1.0) ? a : b).hashCode();
 270         }
 271         System.out.println(total);
 272     }
 273     static void testfp() {
 274         Object a = new Object();
 275         Object b = new Object();;
 276         int total = 0;
 277         for (int i = 0 ; i < 10000; i++) {
 278             int v = i % 4;
 279             total += ((v > 1.0f) ? a : b).hashCode();
 280         }
 281         System.out.println(total);
 282     }
 283 }