001/* 002 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 004 * 005 * This code is free software; you can redistribute it and/or modify it 006 * under the terms of the GNU General Public License version 2 only, as 007 * published by the Free Software Foundation. 008 * 009 * This code is distributed in the hope that it will be useful, but WITHOUT 010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 011 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 012 * version 2 for more details (a copy is included in the LICENSE file that 013 * accompanied this code). 014 * 015 * You should have received a copy of the GNU General Public License version 016 * 2 along with this work; if not, write to the Free Software Foundation, 017 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 018 * 019 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 020 * or visit www.oracle.com if you need additional information or have any 021 * questions. 022 */ 023package com.oracle.graal.jtt.optimize; 024 025import org.junit.*; 026 027import com.oracle.graal.jtt.*; 028 029/** 030 * test some stamps in combination with full loop unrolling and shifts. 031 */ 032public class InferStamp01 extends JTTTest { 033 034 public static int testi0(int arg) { 035 int a = arg; 036 for (int i = 0; i < 2; i++) { 037 a = a >> 16; 038 } 039 return a; 040 } 041 042 @Test 043 public void runi0() throws Throwable { 044 runTest("testi0", 0x7788_99aa); 045 } 046 047 @Test 048 public void runi0neg() throws Throwable { 049 runTest("testi0", 0xf788_99aa); 050 } 051 052 public static int testi1(int arg) { 053 int a = arg; 054 for (int i = 0; i < 2; i++) { 055 a = a >>> 16; 056 } 057 return a; 058 } 059 060 @Test 061 public void runi1() throws Throwable { 062 runTest("testi1", 0x7788_99aa); 063 } 064 065 @Test 066 public void runi1neg() throws Throwable { 067 runTest("testi1", 0xf788_99aa); 068 } 069 070 public static int testi2(int arg) { 071 int a = arg; 072 for (int i = 0; i < 2; i++) { 073 a = a << 16; 074 } 075 return a; 076 } 077 078 @Test 079 public void runi2() throws Throwable { 080 runTest("testi2", 0x7788_99aa); 081 } 082 083 @Test 084 public void runi2neg() throws Throwable { 085 runTest("testi2", 0xf788_99aa); 086 } 087 088 public static long testl0(long arg) { 089 long a = arg; 090 for (long i = 0; i < 2; i++) { 091 a = a >> 32; 092 } 093 return a; 094 } 095 096 @Test 097 public void runl0() throws Throwable { 098 runTest("testl0", 0x3344_5566_7788_99aaL); 099 } 100 101 @Test 102 public void runl0neg() throws Throwable { 103 runTest("testl0", 0xf344_5566_7788_99aaL); 104 } 105 106 public static long testl1(long arg) { 107 long a = arg; 108 for (long i = 0; i < 2; i++) { 109 a = a >>> 32; 110 } 111 return a; 112 } 113 114 @Test 115 public void runl1() throws Throwable { 116 runTest("testl1", 0x3344_5566_7788_99aaL); 117 } 118 119 @Test 120 public void runl1neg() throws Throwable { 121 runTest("testl1", 0xf344_5566_7788_99aaL); 122 } 123 124 public static long testl2(long arg) { 125 long a = arg; 126 for (long i = 0; i < 2; i++) { 127 a = a << 32; 128 } 129 return a; 130 } 131 132 @Test 133 public void runl2() throws Throwable { 134 runTest("testl2", 0x3344_5566_7788_99aaL); 135 } 136 137 @Test 138 public void runl2neg() throws Throwable { 139 runTest("testl2", 0xf344_5566_7788_99aaL); 140 } 141}