changeset 4410:860ae068f4df hs24-b34

Merge
author amurillo
date Thu, 28 Feb 2013 10:45:18 -0800
parents 375a8c57a7f0 (current diff) d323b9b05997 (diff)
children 12619005c5e2
files make/hotspot_version
diffstat 28 files changed, 6050 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/agent/src/os/bsd/MacosxDebuggerLocal.m	Wed Feb 27 16:51:50 2013 -0800
+++ b/agent/src/os/bsd/MacosxDebuggerLocal.m	Thu Feb 28 10:45:18 2013 -0800
@@ -32,6 +32,8 @@
 #import <mach/mach_types.h>
 #import <sys/sysctl.h>
 #import <stdlib.h>
+#import <sys/types.h>
+#import <sys/ptrace.h>
 
 jboolean debug = JNI_FALSE;
 
@@ -347,6 +349,73 @@
   return (jint) usable_tid;
 }
 
+
+static bool ptrace_continue(pid_t pid, int signal) {
+  // pass the signal to the process so we don't swallow it
+  int res;
+  if ((res = ptrace(PT_CONTINUE, pid, (caddr_t)1, signal)) < 0) {
+    fprintf(stderr, "attach: ptrace(PT_CONTINUE, %d) failed with %d\n", pid, res);
+    return false;
+  }
+  return true;
+}
+
+// waits until the ATTACH has stopped the process
+// by signal SIGSTOP
+static bool ptrace_waitpid(pid_t pid) {
+  int ret;
+  int status;
+  while (true) {
+    // Wait for debuggee to stop.
+    ret = waitpid(pid, &status, 0);
+    if (ret >= 0) {
+      if (WIFSTOPPED(status)) {
+        // Any signal will stop the thread, make sure it is SIGSTOP. Otherwise SIGSTOP
+        // will still be pending and delivered when the process is DETACHED and the process
+        // will go to sleep.
+        if (WSTOPSIG(status) == SIGSTOP) {
+          // Debuggee stopped by SIGSTOP.
+          return true;
+        }
+        if (!ptrace_continue(pid, WSTOPSIG(status))) {
+          fprintf(stderr, "attach: Failed to correctly attach to VM. VM might HANG! [PTRACE_CONT failed, stopped by %d]\n", WSTOPSIG(status));
+          return false;
+        }
+      } else {
+        fprintf(stderr, "attach: waitpid(): Child process exited/terminated (status = 0x%x)\n", status);
+        return false;
+      }
+    } else {
+      switch (errno) {
+        case EINTR:
+          continue;
+          break;
+        case ECHILD:
+          fprintf(stderr, "attach: waitpid() failed. Child process pid (%d) does not exist \n", pid);
+          break;
+        case EINVAL:
+          fprintf(stderr, "attach: waitpid() failed. Invalid options argument.\n");
+          break;
+        default:
+          fprintf(stderr, "attach: waitpid() failed. Unexpected error %d\n",errno);
+          break;
+      }
+      return false;
+    }
+  }
+}
+
+// attach to a process/thread specified by "pid"
+static bool ptrace_attach(pid_t pid) {
+  int res;
+  if ((res = ptrace(PT_ATTACH, pid, 0, 0)) < 0) {
+    fprintf(stderr, "ptrace(PT_ATTACH, %d) failed with %d\n", pid, res);
+    return false;
+  } else {
+    return ptrace_waitpid(pid);
+  }
+}
+
 /*
  * Class:     sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
  * Method:    attach0
@@ -359,7 +428,8 @@
   else
     debug = JNI_FALSE;
   if (debug) printf("attach0 called for jpid=%d\n", (int)jpid);
-
+  
+  // get the task from the pid
   kern_return_t result;
   task_t gTask = 0;
   result = task_for_pid(mach_task_self(), jpid, &gTask);
@@ -369,6 +439,13 @@
   }
   putTask(env, this_obj, gTask);
 
+  // use ptrace to stop the process
+  // on os x, ptrace only needs to be called on the process, not the individual threads
+  if (ptrace_attach(jpid) != true) {
+    mach_port_deallocate(mach_task_self(), gTask);
+    THROW_NEW_DEBUGGER_EXCEPTION("Can't attach to the process");
+  }
+
   id symbolicator = nil;
   id jrsSymbolicator = objc_lookUpClass("JRSSymbolicator");
   if (jrsSymbolicator != nil) {
@@ -397,6 +474,21 @@
   if (debug) printf("detach0 called\n");
 
   task_t gTask = getTask(env, this_obj);
+
+  // detach from the ptraced process causing it to resume execution
+  int pid;
+  kern_return_t k_res;
+  k_res = pid_for_task(gTask, &pid);
+  if (k_res != KERN_SUCCESS) {
+    fprintf(stderr, "detach: pid_for_task(%d) failed (%d)\n", pid, k_res);
+  }
+  else {
+    int res = ptrace(PT_DETACH, pid, 0, 0);
+    if (res < 0) {
+      fprintf(stderr, "detach: ptrace(PT_DETACH, %d) failed (%d)\n", pid, res);
+    }
+  }
+  
   mach_port_deallocate(mach_task_self(), gTask);
   id symbolicator = getSymbolicator(env, this_obj);
   if (symbolicator != nil) {
--- a/make/hotspot_version	Wed Feb 27 16:51:50 2013 -0800
+++ b/make/hotspot_version	Thu Feb 28 10:45:18 2013 -0800
@@ -35,7 +35,7 @@
 
 HS_MAJOR_VER=24
 HS_MINOR_VER=0
-HS_BUILD_NUMBER=33
+HS_BUILD_NUMBER=34
 
 JDK_MAJOR_VER=1
 JDK_MINOR_VER=7
--- a/src/cpu/sparc/vm/frame_sparc.cpp	Wed Feb 27 16:51:50 2013 -0800
+++ b/src/cpu/sparc/vm/frame_sparc.cpp	Thu Feb 28 10:45:18 2013 -0800
@@ -216,6 +216,11 @@
       }
     }
 
+    // Could just be some random pointer within the codeBlob
+    if (!_cb->code_contains(_pc)) {
+      return false;
+    }
+
     // Entry frame checks
     if (is_entry_frame()) {
       // an entry frame must have a valid fp.
--- a/src/cpu/x86/vm/frame_x86.cpp	Wed Feb 27 16:51:50 2013 -0800
+++ b/src/cpu/x86/vm/frame_x86.cpp	Thu Feb 28 10:45:18 2013 -0800
@@ -97,7 +97,6 @@
     // check for a valid frame_size, otherwise we are unlikely to get a valid sender_pc
 
     if (!Interpreter::contains(_pc) && _cb->frame_size() <= 0) {
-      //assert(0, "Invalid frame_size");
       return false;
     }
 
@@ -106,20 +105,22 @@
         return false;
       }
     }
+
+    // Could just be some random pointer within the codeBlob
+    if (!_cb->code_contains(_pc)) {
+      return false;
+    }
+
     // Entry frame checks
     if (is_entry_frame()) {
       // an entry frame must have a valid fp.
 
       if (!fp_safe) return false;
-
       // Validate the JavaCallWrapper an entry frame must have
 
       address jcw = (address)entry_frame_call_wrapper();
-
       bool jcw_safe = (jcw < thread->stack_base()) && ( jcw > fp);
-
       return jcw_safe;
-
     }
 
     intptr_t* sender_sp = NULL;
--- a/src/os/solaris/vm/os_solaris.cpp	Wed Feb 27 16:51:50 2013 -0800
+++ b/src/os/solaris/vm/os_solaris.cpp	Thu Feb 28 10:45:18 2013 -0800
@@ -1872,7 +1872,7 @@
 
 // Die immediately, no exit hook, no abort hook, no cleanup.
 void os::die() {
-  _exit(-1);
+  ::abort(); // dump core (for debugging)
 }
 
 // unused
--- a/src/os/windows/vm/os_windows.cpp	Wed Feb 27 16:51:50 2013 -0800
+++ b/src/os/windows/vm/os_windows.cpp	Thu Feb 28 10:45:18 2013 -0800
@@ -1927,7 +1927,7 @@
 
 // a counter for each possible signal value, including signal_thread exit signal
 static volatile jint pending_signals[NSIG+1] = { 0 };
-static HANDLE sig_sem;
+static HANDLE sig_sem = NULL;
 
 void os::signal_init_pd() {
   // Initialize signal structures
@@ -1957,10 +1957,11 @@
 
 void os::signal_notify(int signal_number) {
   BOOL ret;
-
-  Atomic::inc(&pending_signals[signal_number]);
-  ret = ::ReleaseSemaphore(sig_sem, 1, NULL);
-  assert(ret != 0, "ReleaseSemaphore() failed");
+  if (sig_sem != NULL) {
+    Atomic::inc(&pending_signals[signal_number]);
+    ret = ::ReleaseSemaphore(sig_sem, 1, NULL);
+    assert(ret != 0, "ReleaseSemaphore() failed");
+  }
 }
 
 static int check_pending_signals(bool wait_for_signal) {
--- a/src/share/vm/compiler/compileBroker.cpp	Wed Feb 27 16:51:50 2013 -0800
+++ b/src/share/vm/compiler/compileBroker.cpp	Thu Feb 28 10:45:18 2013 -0800
@@ -502,7 +502,7 @@
   ResourceMark rm(thread);
 
   // <task id='9' method='M' osr_bci='X' level='1' blocking='1' stamp='1.234'>
-  if (_compile_id != 0)   log->print(" compile_id='%d'", _compile_id);
+  log->print(" compile_id='%d'", _compile_id);
   if (_osr_bci != CompileBroker::standard_entry_bci) {
     log->print(" compile_kind='osr'");  // same as nmethod::compile_kind
   } // else compile_kind='c2c'
--- a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp	Wed Feb 27 16:51:50 2013 -0800
+++ b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp	Thu Feb 28 10:45:18 2013 -0800
@@ -2285,8 +2285,6 @@
         {
           ReleaseForegroundGC x(this);
           stats().record_cms_begin();
-          register_gc_start(GCCause::_cms_concurrent_mark);
-
           VM_CMS_Initial_Mark initial_mark_op(this);
           VMThread::execute(&initial_mark_op);
         }
@@ -2423,7 +2421,6 @@
 
 void CMSCollector::register_gc_start(GCCause::Cause cause) {
   _cms_start_registered = true;
-  CollectedHeap* heap = GenCollectedHeap::heap();
   _gc_timer_cm->register_gc_start(os::elapsed_counter());
   _gc_tracer_cm->report_gc_start(cause, _gc_timer_cm->gc_start());
 }
--- a/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp	Wed Feb 27 16:51:50 2013 -0800
+++ b/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp	Thu Feb 28 10:45:18 2013 -0800
@@ -145,6 +145,7 @@
                                 );
 #endif /* USDT2 */
 
+  _collector->register_gc_start(GCCause::_cms_concurrent_mark);
   _collector->_gc_timer_cm->register_gc_pause_start("Initial Mark", os::elapsed_counter());
 
   GenCollectedHeap* gch = GenCollectedHeap::heap();
--- a/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp	Wed Feb 27 16:51:50 2013 -0800
+++ b/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp	Thu Feb 28 10:45:18 2013 -0800
@@ -267,7 +267,15 @@
   double max_gc_time = (double) MaxGCPauseMillis / 1000.0;
   double time_slice  = (double) GCPauseIntervalMillis / 1000.0;
   _mmu_tracker = new G1MMUTrackerQueue(time_slice, max_gc_time);
-  _sigma = (double) G1ConfidencePercent / 100.0;
+
+  uintx confidence_perc = G1ConfidencePercent;
+  // Put an artificial ceiling on this so that it's not set to a silly value.
+  if (confidence_perc > 100) {
+    confidence_perc = 100;
+    warning("G1ConfidencePercent is set to a value that is too large, "
+            "it's been updated to %u", confidence_perc);
+  }
+  _sigma = (double) confidence_perc / 100.0;
 
   // start conservatively (around 50ms is about right)
   _concurrent_mark_remark_times_ms->add(0.05);
--- a/src/share/vm/gc_implementation/g1/g1_globals.hpp	Wed Feb 27 16:51:50 2013 -0800
+++ b/src/share/vm/gc_implementation/g1/g1_globals.hpp	Thu Feb 28 10:45:18 2013 -0800
@@ -32,7 +32,7 @@
 
 #define G1_FLAGS(develop, develop_pd, product, product_pd, diagnostic, experimental, notproduct, manageable, product_rw) \
                                                                             \
-  product(intx, G1ConfidencePercent, 50,                                    \
+  product(uintx, G1ConfidencePercent, 50,                                   \
           "Confidence level for MMU/pause predictions")                     \
                                                                             \
   develop(intx, G1MarkingOverheadPercent, 0,                                \
--- a/src/share/vm/gc_implementation/shared/gcTrace.cpp	Wed Feb 27 16:51:50 2013 -0800
+++ b/src/share/vm/gc_implementation/shared/gcTrace.cpp	Thu Feb 28 10:45:18 2013 -0800
@@ -27,15 +27,14 @@
 #include "gc_implementation/shared/gcTimer.hpp"
 #include "gc_implementation/shared/gcTrace.hpp"
 #include "memory/referenceProcessorStats.hpp"
-#include "runtime/atomic.hpp"
 #include "utilities/globalDefinitions.hpp"
 
 #define assert_unset_gc_id() assert(_shared_gc_info.id() == SharedGCInfo::UNSET_GCID, "GC already started?")
 #define assert_set_gc_id() assert(_shared_gc_info.id() != SharedGCInfo::UNSET_GCID, "GC not started?")
 
-static volatile jlong GCTracer_next_gc_id = 0;
+static jlong GCTracer_next_gc_id = 0;
 static GCId create_new_gc_id() {
-  return Atomic::add((jlong)1, &GCTracer_next_gc_id);
+  return GCTracer_next_gc_id++;
 }
 
 void GCTracer::report_gc_start_impl(GCCause::Cause cause, jlong timestamp) {
--- a/src/share/vm/opto/compile.cpp	Wed Feb 27 16:51:50 2013 -0800
+++ b/src/share/vm/opto/compile.cpp	Thu Feb 28 10:45:18 2013 -0800
@@ -884,7 +884,7 @@
   : Phase(Compiler),
     _env(ci_env),
     _log(ci_env->log()),
-    _compile_id(-1),
+    _compile_id(0),
     _save_argument_registers(save_arg_registers),
     _method(NULL),
     _stub_name(stub_name),
--- a/src/share/vm/opto/superword.cpp	Wed Feb 27 16:51:50 2013 -0800
+++ b/src/share/vm/opto/superword.cpp	Thu Feb 28 10:45:18 2013 -0800
@@ -143,7 +143,8 @@
 
   // Ready the block
 
-  construct_bb();
+  if (!construct_bb())
+    return; // Exit if no interesting nodes or complex graph.
 
   dependence_graph();
 
@@ -615,6 +616,7 @@
     if (n == stop) break;
     preds.push(n);
     prev = n;
+    assert(n->is_Mem(), err_msg_res("unexpected node %s", n->Name()));
     n = n->in(MemNode::Memory);
   }
 }
@@ -1578,7 +1580,7 @@
 
 //------------------------------construct_bb---------------------------
 // Construct reverse postorder list of block members
-void SuperWord::construct_bb() {
+bool SuperWord::construct_bb() {
   Node* entry = bb();
 
   assert(_stk.length() == 0,            "stk is empty");
@@ -1596,6 +1598,12 @@
     Node *n = lpt()->_body.at(i);
     set_bb_idx(n, i); // Create a temporary map
     if (in_bb(n)) {
+      if (n->is_LoadStore() || n->is_MergeMem() ||
+          (n->is_Proj() && !n->as_Proj()->is_CFG())) {
+        // Bailout if the loop has LoadStore, MergeMem or data Proj
+        // nodes. Superword optimization does not work with them.
+        return false;
+      }
       bb_ct++;
       if (!n->is_CFG()) {
         bool found = false;
@@ -1620,6 +1628,10 @@
     if (in_bb(n) && (n->is_Phi() && n->bottom_type() == Type::MEMORY)) {
       Node* n_tail  = n->in(LoopNode::LoopBackControl);
       if (n_tail != n->in(LoopNode::EntryControl)) {
+        if (!n_tail->is_Mem()) {
+          assert(n_tail->is_Mem(), err_msg_res("unexpected node for memory slice: %s", n_tail->Name()));
+          return false; // Bailout
+        }
         _mem_slice_head.push(n);
         _mem_slice_tail.push(n_tail);
       }
@@ -1695,6 +1707,7 @@
   }
 #endif
   assert(rpo_idx == -1 && bb_ct == _block.length(), "all block members found");
+  return (_mem_slice_head.length() > 0) || (_data_entry.length() > 0);
 }
 
 //------------------------------initialize_bb---------------------------
--- a/src/share/vm/opto/superword.hpp	Wed Feb 27 16:51:50 2013 -0800
+++ b/src/share/vm/opto/superword.hpp	Thu Feb 28 10:45:18 2013 -0800
@@ -380,7 +380,7 @@
   // Is use->in(u_idx) a vector use?
   bool is_vector_use(Node* use, int u_idx);
   // Construct reverse postorder list of block members
-  void construct_bb();
+  bool construct_bb();
   // Initialize per node info
   void initialize_bb();
   // Insert n into block after pos
--- a/src/share/vm/runtime/os.cpp	Wed Feb 27 16:51:50 2013 -0800
+++ b/src/share/vm/runtime/os.cpp	Thu Feb 28 10:45:18 2013 -0800
@@ -890,7 +890,11 @@
       print = true;
     }
     if (print) {
-      st->print_cr(INTPTR_FORMAT " is an oop", addr);
+      if (p == (HeapWord*) addr) {
+        st->print_cr(INTPTR_FORMAT " is an oop", addr);
+      } else {
+        st->print_cr(INTPTR_FORMAT " is pointing into object: " INTPTR_FORMAT, addr, p);
+      }
       oop(p)->print_on(st);
       if (p != (HeapWord*)x && oop(p)->is_constMethod() &&
           constMethodOop(p)->contains(addr)) {
--- a/src/share/vm/runtime/perfData.cpp	Wed Feb 27 16:51:50 2013 -0800
+++ b/src/share/vm/runtime/perfData.cpp	Thu Feb 28 10:45:18 2013 -0800
@@ -320,6 +320,10 @@
   }
 }
 
+PerfData* PerfDataManager::find_by_name(const char* name) {
+  return _all->find_by_name(name);
+}
+
 PerfDataList* PerfDataManager::all() {
 
   MutexLocker ml(PerfDataManager_lock);
--- a/src/share/vm/runtime/perfData.hpp	Wed Feb 27 16:51:50 2013 -0800
+++ b/src/share/vm/runtime/perfData.hpp	Thu Feb 28 10:45:18 2013 -0800
@@ -692,6 +692,9 @@
     // the given name.
     static bool exists(const char* name) { return _all->contains(name); }
 
+    // method to search for a instrumentation object by name
+    static PerfData* find_by_name(const char* name);
+
     // method to map a CounterNS enumeration to a namespace string
     static const char* ns_to_string(CounterNS ns) {
       return _name_spaces[ns];
--- a/src/share/vm/runtime/vmThread.cpp	Wed Feb 27 16:51:50 2013 -0800
+++ b/src/share/vm/runtime/vmThread.cpp	Thu Feb 28 10:45:18 2013 -0800
@@ -383,10 +383,14 @@
     op->evaluate();
 
     if (event.should_commit()) {
+      bool is_concurrent = op->evaluate_concurrently();
       event.set_operation(op->type());
       event.set_safepoint(op->evaluate_at_safepoint());
-      event.set_blocking(!op->evaluate_concurrently());
-      event.set_caller(op->calling_thread()->osthread()->thread_id());
+      event.set_blocking(!is_concurrent);
+      // Only write caller thread information for non-concurrent vm operations.
+      // For concurrent vm operations, the thread id is set to 0 indicating thread is unknown.
+      // This is because the caller thread could have exited already.
+      event.set_caller(is_concurrent ? 0 : op->calling_thread()->osthread()->thread_id());
       event.commit();
     }
 
--- a/src/share/vm/services/memSnapshot.cpp	Wed Feb 27 16:51:50 2013 -0800
+++ b/src/share/vm/services/memSnapshot.cpp	Thu Feb 28 10:45:18 2013 -0800
@@ -528,7 +528,8 @@
         // an arena record can be followed by a size record, we need to remove both
         if (matched_rec->is_arena_record()) {
           MemPointerRecord* next = (MemPointerRecord*)malloc_snapshot_itr.peek_next();
-          if (next->is_arena_memory_record() && next->is_memory_record_of_arena(matched_rec)) {
+          if (next != NULL && next->is_arena_memory_record() &&
+              next->is_memory_record_of_arena(matched_rec)) {
             malloc_snapshot_itr.remove();
           }
         }
--- a/src/share/vm/trace/trace.xml	Wed Feb 27 16:51:50 2013 -0800
+++ b/src/share/vm/trace/trace.xml	Thu Feb 28 10:45:18 2013 -0800
@@ -283,7 +283,7 @@
       <value type="VMOPERATIONTYPE" field="operation" label="Operation" />
       <value type="BOOLEAN" field="safepoint" label="At Safepoint" description="If the operation occured at a safepoint."/>
       <value type="BOOLEAN" field="blocking" label="Caller Blocked" description="If the calling thread was blocked until the operation was complete."/>
-      <value type="OSTHREAD" field="caller" label="Caller" transition="TO"/>
+      <value type="OSTHREAD" field="caller" label="Caller" transition="TO" description="Thread requesting operation. If non-blocking, will be set to 0 indicating thread is unknown."/>
     </event>
 
   </events>
--- a/src/share/vm/trace/traceStream.hpp	Wed Feb 27 16:51:50 2013 -0800
+++ b/src/share/vm/trace/traceStream.hpp	Thu Feb 28 10:45:18 2013 -0800
@@ -83,7 +83,7 @@
   }
 
   void print_val(const char* label, methodOop& val) {
-    _st.print("%s = %s", label, val->print_string());
+    _st.print("%s = %s", label, val->name_and_sig_as_C_string());
   }
 
   void print_val(const char* label, const char* val) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compiler/8004867/TestIntAtomicCAS.java	Thu Feb 28 10:45:18 2013 -0800
@@ -0,0 +1,969 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+/**
+ * @test
+ * @bug 8004867
+ * @summary VM crashing with assert "share/vm/opto/node.hpp:357 - assert(i < _max) failed: oob"
+ *
+ * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:-OptimizeFill TestIntAtomicCAS
+ * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:+OptimizeFill TestIntAtomicCAS
+ */
+
+import java.util.concurrent.atomic.AtomicIntegerArray;
+
+public class TestIntAtomicCAS {
+  private static final int ARRLEN = 97;
+  private static final int ITERS  = 11000;
+  private static final int OFFSET = 3;
+  private static final int SCALE = 2;
+  private static final int ALIGN_OFF = 8;
+  private static final int UNALIGN_OFF = 5;
+
+  public static void main(String args[]) {
+    System.out.println("Testing Integer array atomic CAS operations");
+    int errn = test(false);
+    if (errn > 0) {
+      System.err.println("FAILED: " + errn + " errors");
+      System.exit(97);
+    }
+    System.out.println("PASSED");
+  }
+
+  static int test(boolean test_only) {
+    AtomicIntegerArray a1 = new AtomicIntegerArray(ARRLEN);
+    AtomicIntegerArray a2 = new AtomicIntegerArray(ARRLEN);
+    // Initialize
+    for (int i=0; i<ARRLEN; i++) {
+      a1.set(i, -1);
+      a2.set(i, -1);
+    }
+    System.out.println("Warmup");
+    for (int i=0; i<ITERS; i++) {
+      test_ci(a1);
+      test_vi(a2, 123, -1);
+      test_cp(a1, a2);
+      test_2ci(a1, a2);
+      test_2vi(a1, a2, 123, 103);
+      test_ci_neg(a1, 123);
+      test_vi_neg(a2, 123, 103);
+      test_cp_neg(a1, a2);
+      test_2ci_neg(a1, a2);
+      test_2vi_neg(a1, a2, 123, 103);
+      test_ci_oppos(a1, 123);
+      test_vi_oppos(a2, 123, 103);
+      test_cp_oppos(a1, a2);
+      test_2ci_oppos(a1, a2);
+      test_2vi_oppos(a1, a2, 123, 103);
+      test_ci_off(a1, 123);
+      test_vi_off(a2, 123, 103);
+      test_cp_off(a1, a2);
+      test_2ci_off(a1, a2);
+      test_2vi_off(a1, a2, 123, 103);
+      test_ci_inv(a1, OFFSET, 123);
+      test_vi_inv(a2, 123, OFFSET, 103);
+      test_cp_inv(a1, a2, OFFSET);
+      test_2ci_inv(a1, a2, OFFSET);
+      test_2vi_inv(a1, a2, 123, 103, OFFSET);
+      test_ci_scl(a1, 123);
+      test_vi_scl(a2, 123, 103);
+      test_cp_scl(a1, a2);
+      test_2ci_scl(a1, a2);
+      test_2vi_scl(a1, a2, 123, 103);
+      test_cp_alndst(a1, a2);
+      test_cp_alnsrc(a1, a2);
+      test_2ci_aln(a1, a2);
+      test_2vi_aln(a1, a2, 123, 103);
+      test_cp_unalndst(a1, a2);
+      test_cp_unalnsrc(a1, a2);
+      test_2ci_unaln(a1, a2);
+      test_2vi_unaln(a1, a2, 123, 103);
+    }
+    // Initialize
+    for (int i=0; i<ARRLEN; i++) {
+      a1.set(i, -1);
+      a2.set(i, -1);
+    }
+    // Test and verify results
+    System.out.println("Verification");
+    int errn = 0;
+    {
+      test_ci(a1);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_ci: a1", i, a1.get(i), -123);
+      }
+      test_vi(a2, 123, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_vi: a2", i, a2.get(i), 123);
+      }
+      test_cp(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_cp: a1", i, a1.get(i), 123);
+      }
+      test_2ci(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_2ci: a1", i, a1.get(i), -123);
+        errn += verify("test_2ci: a2", i, a2.get(i), -103);
+      }
+      test_2vi(a1, a2, 123, 103);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_2vi: a1", i, a1.get(i), 123);
+        errn += verify("test_2vi: a2", i, a2.get(i), 103);
+      }
+      // Reset for negative stride
+      for (int i=0; i<ARRLEN; i++) {
+        a1.set(i, -1);
+        a2.set(i, -1);
+      }
+      test_ci_neg(a1, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_ci_neg: a1", i, a1.get(i), -123);
+      }
+      test_vi_neg(a2, 123, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_vi_neg: a2", i, a2.get(i), 123);
+      }
+      test_cp_neg(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_cp_neg: a1", i, a1.get(i), 123);
+      }
+      test_2ci_neg(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_2ci_neg: a1", i, a1.get(i), -123);
+        errn += verify("test_2ci_neg: a2", i, a2.get(i), -103);
+      }
+      test_2vi_neg(a1, a2, 123, 103);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_2vi_neg: a1", i, a1.get(i), 123);
+        errn += verify("test_2vi_neg: a2", i, a2.get(i), 103);
+      }
+      // Reset for opposite stride
+      for (int i=0; i<ARRLEN; i++) {
+        a1.set(i, -1);
+        a2.set(i, -1);
+      }
+      test_ci_oppos(a1, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_ci_oppos: a1", i, a1.get(i), -123);
+      }
+      test_vi_oppos(a2, 123, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_vi_oppos: a2", i, a2.get(i), 123);
+      }
+      test_cp_oppos(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_cp_oppos: a1", i, a1.get(i), 123);
+      }
+      test_2ci_oppos(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_2ci_oppos: a1", i, a1.get(i), -123);
+        errn += verify("test_2ci_oppos: a2", i, a2.get(i), -103);
+      }
+      test_2vi_oppos(a1, a2, 123, 103);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_2vi_oppos: a1", i, a1.get(i), 123);
+        errn += verify("test_2vi_oppos: a2", i, a2.get(i), 103);
+      }
+      // Reset for indexing with offset
+      for (int i=0; i<ARRLEN; i++) {
+        a1.set(i, -1);
+        a2.set(i, -1);
+      }
+      test_ci_off(a1, -1);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_ci_off: a1", i, a1.get(i), -123);
+      }
+      test_vi_off(a2, 123, -1);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_vi_off: a2", i, a2.get(i), 123);
+      }
+      test_cp_off(a1, a2);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_cp_off: a1", i, a1.get(i), 123);
+      }
+      test_2ci_off(a1, a2);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_2ci_off: a1", i, a1.get(i), -123);
+        errn += verify("test_2ci_off: a2", i, a2.get(i), -103);
+      }
+      test_2vi_off(a1, a2, 123, 103);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_2vi_off: a1", i, a1.get(i), 123);
+        errn += verify("test_2vi_off: a2", i, a2.get(i), 103);
+      }
+      for (int i=0; i<OFFSET; i++) {
+        errn += verify("test_2vi_off: a1", i, a1.get(i), -1);
+        errn += verify("test_2vi_off: a2", i, a2.get(i), -1);
+      }
+      // Reset for indexing with invariant offset
+      for (int i=0; i<ARRLEN; i++) {
+        a1.set(i, -1);
+        a2.set(i, -1);
+      }
+      test_ci_inv(a1, OFFSET, -1);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_ci_inv: a1", i, a1.get(i), -123);
+      }
+      test_vi_inv(a2, 123, OFFSET, -1);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_vi_inv: a2", i, a2.get(i), 123);
+      }
+      test_cp_inv(a1, a2, OFFSET);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_cp_inv: a1", i, a1.get(i), 123);
+      }
+      test_2ci_inv(a1, a2, OFFSET);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_2ci_inv: a1", i, a1.get(i), -123);
+        errn += verify("test_2ci_inv: a2", i, a2.get(i), -103);
+      }
+      test_2vi_inv(a1, a2, 123, 103, OFFSET);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_2vi_inv: a1", i, a1.get(i), 123);
+        errn += verify("test_2vi_inv: a2", i, a2.get(i), 103);
+      }
+      for (int i=0; i<OFFSET; i++) {
+        errn += verify("test_2vi_inv: a1", i, a1.get(i), -1);
+        errn += verify("test_2vi_inv: a2", i, a2.get(i), -1);
+      }
+      // Reset for indexing with scale
+      for (int i=0; i<ARRLEN; i++) {
+        a1.set(i, -1);
+        a2.set(i, -1);
+      }
+      test_ci_scl(a1, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        int val = (i%SCALE != 0) ? -1 : -123;
+        errn += verify("test_ci_scl: a1", i, a1.get(i), val);
+      }
+      test_vi_scl(a2, 123, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        int val = (i%SCALE != 0) ? -1 : 123;
+        errn += verify("test_vi_scl: a2", i, a2.get(i), val);
+      }
+      test_cp_scl(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        int val = (i%SCALE != 0) ? -1 : 123;
+        errn += verify("test_cp_scl: a1", i, a1.get(i), val);
+      }
+      test_2ci_scl(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        if (i%SCALE != 0) {
+          errn += verify("test_2ci_scl: a1", i, a1.get(i), -1);
+        } else if (i*SCALE < ARRLEN) {
+          errn += verify("test_2ci_scl: a1", i*SCALE, a1.get(i*SCALE), -123);
+        }
+        if (i%SCALE != 0) {
+          errn += verify("test_2ci_scl: a2", i, a2.get(i), -1);
+        } else if (i*SCALE < ARRLEN) {
+          errn += verify("test_2ci_scl: a2", i*SCALE, a2.get(i*SCALE), -103);
+        }
+      }
+      test_2vi_scl(a1, a2, 123, 103);
+      for (int i=0; i<ARRLEN; i++) {
+        if (i%SCALE != 0) {
+          errn += verify("test_2vi_scl: a1", i, a1.get(i), -1);
+        } else if (i*SCALE < ARRLEN) {
+          errn += verify("test_2vi_scl: a1", i*SCALE, a1.get(i*SCALE), 123);
+        }
+        if (i%SCALE != 0) {
+          errn += verify("test_2vi_scl: a2", i, a2.get(i), -1);
+        } else if (i*SCALE < ARRLEN) {
+          errn += verify("test_2vi_scl: a2", i*SCALE, a2.get(i*SCALE), 103);
+        }
+      }
+      // Reset for 2 arrays with relative aligned offset
+      for (int i=0; i<ARRLEN; i++) {
+        a1.set(i, -1);
+        a2.set(i, -1);
+      }
+      test_vi(a2, 123, -1);
+      test_cp_alndst(a1, a2);
+      for (int i=0; i<ALIGN_OFF; i++) {
+        errn += verify("test_cp_alndst: a1", i, a1.get(i), -1);
+      }
+      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_cp_alndst: a1", i, a1.get(i), 123);
+      }
+      for (int i=0; i<ALIGN_OFF; i++) {
+        a1.set(i, 123);
+      }
+      test_vi(a2, -123, 123);
+      test_cp_alnsrc(a1, a2);
+      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+        errn += verify("test_cp_alnsrc: a1", i, a1.get(i), -123);
+      }
+      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_cp_alnsrc: a1", i, a1.get(i), 123);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1.set(i, -1);
+        a2.set(i, -1);
+      }
+      test_2ci_aln(a1, a2);
+      for (int i=0; i<ALIGN_OFF; i++) {
+        errn += verify("test_2ci_aln: a1", i, a1.get(i), -1);
+      }
+      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2ci_aln: a1", i, a1.get(i), -123);
+      }
+      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+        errn += verify("test_2ci_aln: a2", i, a2.get(i), -103);
+      }
+      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2ci_aln: a2", i, a2.get(i), -1);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1.set(i, -1);
+        a2.set(i, -1);
+      }
+      test_2vi_aln(a1, a2, 123, 103);
+      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+        errn += verify("test_2vi_aln: a1", i, a1.get(i), 123);
+      }
+      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2vi_aln: a1", i, a1.get(i), -1);
+      }
+      for (int i=0; i<ALIGN_OFF; i++) {
+        errn += verify("test_2vi_aln: a2", i, a2.get(i), -1);
+      }
+      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2vi_aln: a2", i, a2.get(i), 103);
+      }
+
+      // Reset for 2 arrays with relative unaligned offset
+      for (int i=0; i<ARRLEN; i++) {
+        a1.set(i, -1);
+        a2.set(i, -1);
+      }
+      test_vi(a2, 123, -1);
+      test_cp_unalndst(a1, a2);
+      for (int i=0; i<UNALIGN_OFF; i++) {
+        errn += verify("test_cp_unalndst: a1", i, a1.get(i), -1);
+      }
+      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_cp_unalndst: a1", i, a1.get(i), 123);
+      }
+      test_vi(a2, -123, 123);
+      test_cp_unalnsrc(a1, a2);
+      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+        errn += verify("test_cp_unalnsrc: a1", i, a1.get(i), -123);
+      }
+      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_cp_unalnsrc: a1", i, a1.get(i), 123);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1.set(i, -1);
+        a2.set(i, -1);
+      }
+      test_2ci_unaln(a1, a2);
+      for (int i=0; i<UNALIGN_OFF; i++) {
+        errn += verify("test_2ci_unaln: a1", i, a1.get(i), -1);
+      }
+      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2ci_unaln: a1", i, a1.get(i), -123);
+      }
+      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+        errn += verify("test_2ci_unaln: a2", i, a2.get(i), -103);
+      }
+      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2ci_unaln: a2", i, a2.get(i), -1);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1.set(i, -1);
+        a2.set(i, -1);
+      }
+      test_2vi_unaln(a1, a2, 123, 103);
+      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+        errn += verify("test_2vi_unaln: a1", i, a1.get(i), 123);
+      }
+      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2vi_unaln: a1", i, a1.get(i), -1);
+      }
+      for (int i=0; i<UNALIGN_OFF; i++) {
+        errn += verify("test_2vi_unaln: a2", i, a2.get(i), -1);
+      }
+      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2vi_unaln: a2", i, a2.get(i), 103);
+      }
+
+      // Reset for aligned overlap initialization
+      for (int i=0; i<ALIGN_OFF; i++) {
+        a1.set(i, i);
+      }
+      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+        a1.set(i, -1);
+      }
+      test_cp_alndst(a1, a1);
+      for (int i=0; i<ARRLEN; i++) {
+        int v = i%ALIGN_OFF;
+        errn += verify("test_cp_alndst_overlap: a1", i, a1.get(i), v);
+      }
+      for (int i=0; i<ALIGN_OFF; i++) {
+        a1.set((i+ALIGN_OFF), -1);
+      }
+      test_cp_alnsrc(a1, a1);
+      for (int i=0; i<ALIGN_OFF; i++) {
+        errn += verify("test_cp_alnsrc_overlap: a1", i, a1.get(i), -1);
+      }
+      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+        int v = i%ALIGN_OFF;
+        errn += verify("test_cp_alnsrc_overlap: a1", i, a1.get(i), v);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1.set(i, -1);
+      }
+      test_2ci_aln(a1, a1);
+      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+        errn += verify("test_2ci_aln_overlap: a1", i, a1.get(i), -103);
+      }
+      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2ci_aln_overlap: a1", i, a1.get(i), -123);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1.set(i, -1);
+      }
+      test_2vi_aln(a1, a1, 123, 103);
+      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+        errn += verify("test_2vi_aln_overlap: a1", i, a1.get(i), 123);
+      }
+      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2vi_aln_overlap: a1", i, a1.get(i), 103);
+      }
+
+      // Reset for unaligned overlap initialization
+      for (int i=0; i<UNALIGN_OFF; i++) {
+        a1.set(i, i);
+      }
+      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+        a1.set(i, -1);
+      }
+      test_cp_unalndst(a1, a1);
+      for (int i=0; i<ARRLEN; i++) {
+        int v = i%UNALIGN_OFF;
+        errn += verify("test_cp_unalndst_overlap: a1", i, a1.get(i), v);
+      }
+      for (int i=0; i<UNALIGN_OFF; i++) {
+        a1.set((i+UNALIGN_OFF), -1);
+      }
+      test_cp_unalnsrc(a1, a1);
+      for (int i=0; i<UNALIGN_OFF; i++) {
+        errn += verify("test_cp_unalnsrc_overlap: a1", i, a1.get(i), -1);
+      }
+      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+        int v = i%UNALIGN_OFF;
+        errn += verify("test_cp_unalnsrc_overlap: a1", i, a1.get(i), v);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1.set(i, -1);
+      }
+      test_2ci_unaln(a1, a1);
+      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+        errn += verify("test_2ci_unaln_overlap: a1", i, a1.get(i), -103);
+      }
+      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2ci_unaln_overlap: a1", i, a1.get(i), -123);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1.set(i, -1);
+      }
+      test_2vi_unaln(a1, a1, 123, 103);
+      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+        errn += verify("test_2vi_unaln_overlap: a1", i, a1.get(i), 123);
+      }
+      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2vi_unaln_overlap: a1", i, a1.get(i), 103);
+      }
+
+    }
+
+    if (errn > 0 || test_only)
+      return errn;
+
+    // Initialize
+    for (int i=0; i<ARRLEN; i++) {
+      a1.set(i, -1);
+      a2.set(i, -1);
+    }
+    System.out.println("Time");
+    long start, end;
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_ci(a1);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_ci: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_vi(a2, 123, -1);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_vi: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_ci_neg(a1, 123);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_ci_neg: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_vi_neg(a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_vi_neg: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_neg(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_neg: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_neg(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_neg: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_neg(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_neg: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_ci_oppos(a1, 123);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_ci_oppos: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_vi_oppos(a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_vi_oppos: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_oppos(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_oppos: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_oppos(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_oppos: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_oppos(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_oppos: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_ci_off(a1, 123);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_ci_off: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_vi_off(a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_vi_off: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_off(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_off: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_off(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_off: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_off(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_off: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_ci_inv(a1, OFFSET, 123);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_ci_inv: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_vi_inv(a2, 123, OFFSET, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_vi_inv: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_inv(a1, a2, OFFSET);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_inv: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_inv(a1, a2, OFFSET);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_inv: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_inv(a1, a2, 123, 103, OFFSET);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_inv: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_ci_scl(a1, 123);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_ci_scl: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_vi_scl(a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_vi_scl: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_scl(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_scl: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_scl(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_scl: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_scl(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_scl: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_alndst(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_alndst: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_alnsrc(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_alnsrc: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_aln(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_aln: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_aln(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_aln: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_unalndst(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_unalndst: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_unalnsrc(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_unalnsrc: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_unaln(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_unaln: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_unaln(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_unaln: " + (end - start));
+
+    return errn;
+  }
+
+  static void test_ci(AtomicIntegerArray a) {
+    for (int i = 0; i < ARRLEN; i+=1) {
+      a.compareAndSet(i, -1, -123);
+    }
+  }
+  static void test_vi(AtomicIntegerArray a, int b, int old) {
+    for (int i = 0; i < ARRLEN; i+=1) {
+      a.compareAndSet(i, old, b);
+    }
+  }
+  static void test_cp(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = 0; i < ARRLEN; i+=1) {
+      a.compareAndSet(i, -123, b.get(i));
+    }
+  }
+  static void test_2ci(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = 0; i < ARRLEN; i+=1) {
+      a.compareAndSet(i, 123, -123);
+      b.compareAndSet(i, 123, -103);
+    }
+  }
+  static void test_2vi(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
+    for (int i = 0; i < ARRLEN; i+=1) {
+      a.compareAndSet(i, -123, c);
+      b.compareAndSet(i, -103, d);
+    }
+  }
+  static void test_ci_neg(AtomicIntegerArray a, int old) {
+    for (int i = ARRLEN-1; i >= 0; i-=1) {
+      a.compareAndSet(i, old, -123);
+    }
+  }
+  static void test_vi_neg(AtomicIntegerArray a, int b, int old) {
+    for (int i = ARRLEN-1; i >= 0; i-=1) {
+      a.compareAndSet(i, old, b);
+    }
+  }
+  static void test_cp_neg(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = ARRLEN-1; i >= 0; i-=1) {
+      a.compareAndSet(i, -123, b.get(i));
+    }
+  }
+  static void test_2ci_neg(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = ARRLEN-1; i >= 0; i-=1) {
+      a.compareAndSet(i, 123, -123);
+      b.compareAndSet(i, 123, -103);
+    }
+  }
+  static void test_2vi_neg(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
+    for (int i = ARRLEN-1; i >= 0; i-=1) {
+      a.compareAndSet(i, -123, c);
+      b.compareAndSet(i, -103, d);
+    }
+  }
+  static void test_ci_oppos(AtomicIntegerArray a, int old) {
+    int limit = ARRLEN-1;
+    for (int i = 0; i < ARRLEN; i+=1) {
+      a.compareAndSet((limit-i), old, -123);
+    }
+  }
+  static void test_vi_oppos(AtomicIntegerArray a, int b, int old) {
+    int limit = ARRLEN-1;
+    for (int i = limit; i >= 0; i-=1) {
+      a.compareAndSet((limit-i), old, b);
+    }
+  }
+  static void test_cp_oppos(AtomicIntegerArray a, AtomicIntegerArray b) {
+    int limit = ARRLEN-1;
+    for (int i = 0; i < ARRLEN; i+=1) {
+      a.compareAndSet(i, -123, b.get(limit-i));
+    }
+  }
+  static void test_2ci_oppos(AtomicIntegerArray a, AtomicIntegerArray b) {
+    int limit = ARRLEN-1;
+    for (int i = 0; i < ARRLEN; i+=1) {
+      a.compareAndSet((limit-i), 123, -123);
+      b.compareAndSet(i, 123, -103);
+    }
+  }
+  static void test_2vi_oppos(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
+    int limit = ARRLEN-1;
+    for (int i = limit; i >= 0; i-=1) {
+      a.compareAndSet(i, -123, c);
+      b.compareAndSet((limit-i), -103, d);
+    }
+  }
+  static void test_ci_off(AtomicIntegerArray a, int old) {
+    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
+      a.compareAndSet((i+OFFSET), old, -123);
+    }
+  }
+  static void test_vi_off(AtomicIntegerArray a, int b, int old) {
+    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
+      a.compareAndSet((i+OFFSET), old, b);
+    }
+  }
+  static void test_cp_off(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
+      a.compareAndSet((i+OFFSET), -123, b.get(i+OFFSET));
+    }
+  }
+  static void test_2ci_off(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
+      a.compareAndSet((i+OFFSET), 123, -123);
+      b.compareAndSet((i+OFFSET), 123, -103);
+    }
+  }
+  static void test_2vi_off(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
+    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
+      a.compareAndSet((i+OFFSET), -123, c);
+      b.compareAndSet((i+OFFSET), -103, d);
+    }
+  }
+  static void test_ci_inv(AtomicIntegerArray a, int k, int old) {
+    for (int i = 0; i < ARRLEN-k; i+=1) {
+      a.compareAndSet((i+k), old, -123);
+    }
+  }
+  static void test_vi_inv(AtomicIntegerArray a, int b, int k, int old) {
+    for (int i = 0; i < ARRLEN-k; i+=1) {
+      a.compareAndSet((i+k), old, b);
+    }
+  }
+  static void test_cp_inv(AtomicIntegerArray a, AtomicIntegerArray b, int k) {
+    for (int i = 0; i < ARRLEN-k; i+=1) {
+      a.compareAndSet((i+k), -123, b.get(i+k));
+    }
+  }
+  static void test_2ci_inv(AtomicIntegerArray a, AtomicIntegerArray b, int k) {
+    for (int i = 0; i < ARRLEN-k; i+=1) {
+      a.compareAndSet((i+k), 123, -123);
+      b.compareAndSet((i+k), 123, -103);
+    }
+  }
+  static void test_2vi_inv(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d, int k) {
+    for (int i = 0; i < ARRLEN-k; i+=1) {
+      a.compareAndSet((i+k), -123, c);
+      b.compareAndSet((i+k), -103, d);
+    }
+  }
+  static void test_ci_scl(AtomicIntegerArray a, int old) {
+    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
+      a.compareAndSet((i*SCALE), old, -123);
+    }
+  }
+  static void test_vi_scl(AtomicIntegerArray a, int b, int old) {
+    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
+      a.compareAndSet((i*SCALE), old, b);
+    }
+  }
+  static void test_cp_scl(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
+      a.compareAndSet((i*SCALE), -123, b.get(i*SCALE));
+    }
+  }
+  static void test_2ci_scl(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
+      a.compareAndSet((i*SCALE), 123, -123);
+      b.compareAndSet((i*SCALE), 123, -103);
+    }
+  }
+  static void test_2vi_scl(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
+    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
+      a.compareAndSet((i*SCALE), -123, c);
+      b.compareAndSet((i*SCALE), -103, d);
+    }
+  }
+  static void test_cp_alndst(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
+      a.compareAndSet((i+ALIGN_OFF), -1, b.get(i));
+    }
+  }
+  static void test_cp_alnsrc(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
+      a.getAndSet(i, b.get(i+ALIGN_OFF));
+    }
+  }
+  static void test_2ci_aln(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
+      a.compareAndSet((i+ALIGN_OFF), -1, -123);
+      b.getAndSet(i, -103);
+    }
+  }
+  static void test_2vi_aln(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
+    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
+      a.getAndSet(i, c);
+      b.getAndSet((i+ALIGN_OFF), d);
+    }
+  }
+  static void test_cp_unalndst(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
+      a.compareAndSet((i+UNALIGN_OFF), -1, b.get(i));
+    }
+  }
+  static void test_cp_unalnsrc(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
+      a.getAndSet(i, b.get(i+UNALIGN_OFF));
+    }
+  }
+  static void test_2ci_unaln(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
+      a.compareAndSet((i+UNALIGN_OFF), -1, -123);
+      b.getAndSet(i, -103);
+    }
+  }
+  static void test_2vi_unaln(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
+    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
+      a.getAndSet(i, c);
+      b.getAndSet((i+UNALIGN_OFF), d);
+    }
+  }
+
+  static int verify(String text, int i, int elem, int val) {
+    if (elem != val) {
+      System.err.println(text + "[" + i + "] = " + elem + " != " + val);
+      return 1;
+    }
+    return 0;
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compiler/8004867/TestIntAtomicOrdered.java	Thu Feb 28 10:45:18 2013 -0800
@@ -0,0 +1,969 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+/**
+ * @test
+ * @bug 8004867
+ * @summary VM crashing with assert "share/vm/opto/node.hpp:357 - assert(i < _max) failed: oob"
+ *
+ * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:-OptimizeFill TestIntAtomicOrdered
+ * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:+OptimizeFill TestIntAtomicOrdered
+ */
+
+import java.util.concurrent.atomic.AtomicIntegerArray;
+
+public class TestIntAtomicOrdered {
+  private static final int ARRLEN = 97;
+  private static final int ITERS  = 11000;
+  private static final int OFFSET = 3;
+  private static final int SCALE = 2;
+  private static final int ALIGN_OFF = 8;
+  private static final int UNALIGN_OFF = 5;
+
+  public static void main(String args[]) {
+    System.out.println("Testing Integer array atomic ordered operations");
+    int errn = test(false);
+    if (errn > 0) {
+      System.err.println("FAILED: " + errn + " errors");
+      System.exit(97);
+    }
+    System.out.println("PASSED");
+  }
+
+  static int test(boolean test_only) {
+    AtomicIntegerArray a1 = new AtomicIntegerArray(ARRLEN);
+    AtomicIntegerArray a2 = new AtomicIntegerArray(ARRLEN);
+    // Initialize
+    for (int i=0; i<ARRLEN; i++) {
+      a1.lazySet(i, -1);
+      a2.lazySet(i, -1);
+    }
+    System.out.println("Warmup");
+    for (int i=0; i<ITERS; i++) {
+      test_ci(a1);
+      test_vi(a2, 123, -1);
+      test_cp(a1, a2);
+      test_2ci(a1, a2);
+      test_2vi(a1, a2, 123, 103);
+      test_ci_neg(a1, 123);
+      test_vi_neg(a2, 123, 103);
+      test_cp_neg(a1, a2);
+      test_2ci_neg(a1, a2);
+      test_2vi_neg(a1, a2, 123, 103);
+      test_ci_oppos(a1, 123);
+      test_vi_oppos(a2, 123, 103);
+      test_cp_oppos(a1, a2);
+      test_2ci_oppos(a1, a2);
+      test_2vi_oppos(a1, a2, 123, 103);
+      test_ci_off(a1, 123);
+      test_vi_off(a2, 123, 103);
+      test_cp_off(a1, a2);
+      test_2ci_off(a1, a2);
+      test_2vi_off(a1, a2, 123, 103);
+      test_ci_inv(a1, OFFSET, 123);
+      test_vi_inv(a2, 123, OFFSET, 103);
+      test_cp_inv(a1, a2, OFFSET);
+      test_2ci_inv(a1, a2, OFFSET);
+      test_2vi_inv(a1, a2, 123, 103, OFFSET);
+      test_ci_scl(a1, 123);
+      test_vi_scl(a2, 123, 103);
+      test_cp_scl(a1, a2);
+      test_2ci_scl(a1, a2);
+      test_2vi_scl(a1, a2, 123, 103);
+      test_cp_alndst(a1, a2);
+      test_cp_alnsrc(a1, a2);
+      test_2ci_aln(a1, a2);
+      test_2vi_aln(a1, a2, 123, 103);
+      test_cp_unalndst(a1, a2);
+      test_cp_unalnsrc(a1, a2);
+      test_2ci_unaln(a1, a2);
+      test_2vi_unaln(a1, a2, 123, 103);
+    }
+    // Initialize
+    for (int i=0; i<ARRLEN; i++) {
+      a1.lazySet(i, -1);
+      a2.lazySet(i, -1);
+    }
+    // Test and verify results
+    System.out.println("Verification");
+    int errn = 0;
+    {
+      test_ci(a1);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_ci: a1", i, a1.get(i), -123);
+      }
+      test_vi(a2, 123, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_vi: a2", i, a2.get(i), 123);
+      }
+      test_cp(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_cp: a1", i, a1.get(i), 123);
+      }
+      test_2ci(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_2ci: a1", i, a1.get(i), -123);
+        errn += verify("test_2ci: a2", i, a2.get(i), -103);
+      }
+      test_2vi(a1, a2, 123, 103);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_2vi: a1", i, a1.get(i), 123);
+        errn += verify("test_2vi: a2", i, a2.get(i), 103);
+      }
+      // Reset for negative stride
+      for (int i=0; i<ARRLEN; i++) {
+        a1.lazySet(i, -1);
+        a2.lazySet(i, -1);
+      }
+      test_ci_neg(a1, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_ci_neg: a1", i, a1.get(i), -123);
+      }
+      test_vi_neg(a2, 123, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_vi_neg: a2", i, a2.get(i), 123);
+      }
+      test_cp_neg(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_cp_neg: a1", i, a1.get(i), 123);
+      }
+      test_2ci_neg(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_2ci_neg: a1", i, a1.get(i), -123);
+        errn += verify("test_2ci_neg: a2", i, a2.get(i), -103);
+      }
+      test_2vi_neg(a1, a2, 123, 103);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_2vi_neg: a1", i, a1.get(i), 123);
+        errn += verify("test_2vi_neg: a2", i, a2.get(i), 103);
+      }
+      // Reset for opposite stride
+      for (int i=0; i<ARRLEN; i++) {
+        a1.lazySet(i, -1);
+        a2.lazySet(i, -1);
+      }
+      test_ci_oppos(a1, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_ci_oppos: a1", i, a1.get(i), -123);
+      }
+      test_vi_oppos(a2, 123, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_vi_oppos: a2", i, a2.get(i), 123);
+      }
+      test_cp_oppos(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_cp_oppos: a1", i, a1.get(i), 123);
+      }
+      test_2ci_oppos(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_2ci_oppos: a1", i, a1.get(i), -123);
+        errn += verify("test_2ci_oppos: a2", i, a2.get(i), -103);
+      }
+      test_2vi_oppos(a1, a2, 123, 103);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_2vi_oppos: a1", i, a1.get(i), 123);
+        errn += verify("test_2vi_oppos: a2", i, a2.get(i), 103);
+      }
+      // Reset for indexing with offset
+      for (int i=0; i<ARRLEN; i++) {
+        a1.lazySet(i, -1);
+        a2.lazySet(i, -1);
+      }
+      test_ci_off(a1, -1);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_ci_off: a1", i, a1.get(i), -123);
+      }
+      test_vi_off(a2, 123, -1);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_vi_off: a2", i, a2.get(i), 123);
+      }
+      test_cp_off(a1, a2);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_cp_off: a1", i, a1.get(i), 123);
+      }
+      test_2ci_off(a1, a2);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_2ci_off: a1", i, a1.get(i), -123);
+        errn += verify("test_2ci_off: a2", i, a2.get(i), -103);
+      }
+      test_2vi_off(a1, a2, 123, 103);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_2vi_off: a1", i, a1.get(i), 123);
+        errn += verify("test_2vi_off: a2", i, a2.get(i), 103);
+      }
+      for (int i=0; i<OFFSET; i++) {
+        errn += verify("test_2vi_off: a1", i, a1.get(i), -1);
+        errn += verify("test_2vi_off: a2", i, a2.get(i), -1);
+      }
+      // Reset for indexing with invariant offset
+      for (int i=0; i<ARRLEN; i++) {
+        a1.lazySet(i, -1);
+        a2.lazySet(i, -1);
+      }
+      test_ci_inv(a1, OFFSET, -1);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_ci_inv: a1", i, a1.get(i), -123);
+      }
+      test_vi_inv(a2, 123, OFFSET, -1);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_vi_inv: a2", i, a2.get(i), 123);
+      }
+      test_cp_inv(a1, a2, OFFSET);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_cp_inv: a1", i, a1.get(i), 123);
+      }
+      test_2ci_inv(a1, a2, OFFSET);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_2ci_inv: a1", i, a1.get(i), -123);
+        errn += verify("test_2ci_inv: a2", i, a2.get(i), -103);
+      }
+      test_2vi_inv(a1, a2, 123, 103, OFFSET);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_2vi_inv: a1", i, a1.get(i), 123);
+        errn += verify("test_2vi_inv: a2", i, a2.get(i), 103);
+      }
+      for (int i=0; i<OFFSET; i++) {
+        errn += verify("test_2vi_inv: a1", i, a1.get(i), -1);
+        errn += verify("test_2vi_inv: a2", i, a2.get(i), -1);
+      }
+      // Reset for indexing with scale
+      for (int i=0; i<ARRLEN; i++) {
+        a1.lazySet(i, -1);
+        a2.lazySet(i, -1);
+      }
+      test_ci_scl(a1, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        int val = (i%SCALE != 0) ? -1 : -123;
+        errn += verify("test_ci_scl: a1", i, a1.get(i), val);
+      }
+      test_vi_scl(a2, 123, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        int val = (i%SCALE != 0) ? -1 : 123;
+        errn += verify("test_vi_scl: a2", i, a2.get(i), val);
+      }
+      test_cp_scl(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        int val = (i%SCALE != 0) ? -1 : 123;
+        errn += verify("test_cp_scl: a1", i, a1.get(i), val);
+      }
+      test_2ci_scl(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        if (i%SCALE != 0) {
+          errn += verify("test_2ci_scl: a1", i, a1.get(i), -1);
+        } else if (i*SCALE < ARRLEN) {
+          errn += verify("test_2ci_scl: a1", i*SCALE, a1.get(i*SCALE), -123);
+        }
+        if (i%SCALE != 0) {
+          errn += verify("test_2ci_scl: a2", i, a2.get(i), -1);
+        } else if (i*SCALE < ARRLEN) {
+          errn += verify("test_2ci_scl: a2", i*SCALE, a2.get(i*SCALE), -103);
+        }
+      }
+      test_2vi_scl(a1, a2, 123, 103);
+      for (int i=0; i<ARRLEN; i++) {
+        if (i%SCALE != 0) {
+          errn += verify("test_2vi_scl: a1", i, a1.get(i), -1);
+        } else if (i*SCALE < ARRLEN) {
+          errn += verify("test_2vi_scl: a1", i*SCALE, a1.get(i*SCALE), 123);
+        }
+        if (i%SCALE != 0) {
+          errn += verify("test_2vi_scl: a2", i, a2.get(i), -1);
+        } else if (i*SCALE < ARRLEN) {
+          errn += verify("test_2vi_scl: a2", i*SCALE, a2.get(i*SCALE), 103);
+        }
+      }
+      // Reset for 2 arrays with relative aligned offset
+      for (int i=0; i<ARRLEN; i++) {
+        a1.lazySet(i, -1);
+        a2.lazySet(i, -1);
+      }
+      test_vi(a2, 123, -1);
+      test_cp_alndst(a1, a2);
+      for (int i=0; i<ALIGN_OFF; i++) {
+        errn += verify("test_cp_alndst: a1", i, a1.get(i), -1);
+      }
+      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_cp_alndst: a1", i, a1.get(i), 123);
+      }
+      for (int i=0; i<ALIGN_OFF; i++) {
+        a1.lazySet(i, 123);
+      }
+      test_vi(a2, -123, 123);
+      test_cp_alnsrc(a1, a2);
+      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+        errn += verify("test_cp_alnsrc: a1", i, a1.get(i), -123);
+      }
+      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_cp_alnsrc: a1", i, a1.get(i), 123);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1.lazySet(i, -1);
+        a2.lazySet(i, -1);
+      }
+      test_2ci_aln(a1, a2);
+      for (int i=0; i<ALIGN_OFF; i++) {
+        errn += verify("test_2ci_aln: a1", i, a1.get(i), -1);
+      }
+      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2ci_aln: a1", i, a1.get(i), -123);
+      }
+      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+        errn += verify("test_2ci_aln: a2", i, a2.get(i), -103);
+      }
+      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2ci_aln: a2", i, a2.get(i), -1);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1.lazySet(i, -1);
+        a2.lazySet(i, -1);
+      }
+      test_2vi_aln(a1, a2, 123, 103);
+      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+        errn += verify("test_2vi_aln: a1", i, a1.get(i), 123);
+      }
+      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2vi_aln: a1", i, a1.get(i), -1);
+      }
+      for (int i=0; i<ALIGN_OFF; i++) {
+        errn += verify("test_2vi_aln: a2", i, a2.get(i), -1);
+      }
+      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2vi_aln: a2", i, a2.get(i), 103);
+      }
+
+      // Reset for 2 arrays with relative unaligned offset
+      for (int i=0; i<ARRLEN; i++) {
+        a1.lazySet(i, -1);
+        a2.lazySet(i, -1);
+      }
+      test_vi(a2, 123, -1);
+      test_cp_unalndst(a1, a2);
+      for (int i=0; i<UNALIGN_OFF; i++) {
+        errn += verify("test_cp_unalndst: a1", i, a1.get(i), -1);
+      }
+      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_cp_unalndst: a1", i, a1.get(i), 123);
+      }
+      test_vi(a2, -123, 123);
+      test_cp_unalnsrc(a1, a2);
+      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+        errn += verify("test_cp_unalnsrc: a1", i, a1.get(i), -123);
+      }
+      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_cp_unalnsrc: a1", i, a1.get(i), 123);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1.lazySet(i, -1);
+        a2.lazySet(i, -1);
+      }
+      test_2ci_unaln(a1, a2);
+      for (int i=0; i<UNALIGN_OFF; i++) {
+        errn += verify("test_2ci_unaln: a1", i, a1.get(i), -1);
+      }
+      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2ci_unaln: a1", i, a1.get(i), -123);
+      }
+      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+        errn += verify("test_2ci_unaln: a2", i, a2.get(i), -103);
+      }
+      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2ci_unaln: a2", i, a2.get(i), -1);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1.lazySet(i, -1);
+        a2.lazySet(i, -1);
+      }
+      test_2vi_unaln(a1, a2, 123, 103);
+      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+        errn += verify("test_2vi_unaln: a1", i, a1.get(i), 123);
+      }
+      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2vi_unaln: a1", i, a1.get(i), -1);
+      }
+      for (int i=0; i<UNALIGN_OFF; i++) {
+        errn += verify("test_2vi_unaln: a2", i, a2.get(i), -1);
+      }
+      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2vi_unaln: a2", i, a2.get(i), 103);
+      }
+
+      // Reset for aligned overlap initialization
+      for (int i=0; i<ALIGN_OFF; i++) {
+        a1.lazySet(i, i);
+      }
+      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+        a1.lazySet(i, -1);
+      }
+      test_cp_alndst(a1, a1);
+      for (int i=0; i<ARRLEN; i++) {
+        int v = i%ALIGN_OFF;
+        errn += verify("test_cp_alndst_overlap: a1", i, a1.get(i), v);
+      }
+      for (int i=0; i<ALIGN_OFF; i++) {
+        a1.lazySet((i+ALIGN_OFF), -1);
+      }
+      test_cp_alnsrc(a1, a1);
+      for (int i=0; i<ALIGN_OFF; i++) {
+        errn += verify("test_cp_alnsrc_overlap: a1", i, a1.get(i), -1);
+      }
+      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+        int v = i%ALIGN_OFF;
+        errn += verify("test_cp_alnsrc_overlap: a1", i, a1.get(i), v);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1.lazySet(i, -1);
+      }
+      test_2ci_aln(a1, a1);
+      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+        errn += verify("test_2ci_aln_overlap: a1", i, a1.get(i), -103);
+      }
+      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2ci_aln_overlap: a1", i, a1.get(i), -123);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1.lazySet(i, -1);
+      }
+      test_2vi_aln(a1, a1, 123, 103);
+      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+        errn += verify("test_2vi_aln_overlap: a1", i, a1.get(i), 123);
+      }
+      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2vi_aln_overlap: a1", i, a1.get(i), 103);
+      }
+
+      // Reset for unaligned overlap initialization
+      for (int i=0; i<UNALIGN_OFF; i++) {
+        a1.lazySet(i, i);
+      }
+      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+        a1.lazySet(i, -1);
+      }
+      test_cp_unalndst(a1, a1);
+      for (int i=0; i<ARRLEN; i++) {
+        int v = i%UNALIGN_OFF;
+        errn += verify("test_cp_unalndst_overlap: a1", i, a1.get(i), v);
+      }
+      for (int i=0; i<UNALIGN_OFF; i++) {
+        a1.lazySet((i+UNALIGN_OFF), -1);
+      }
+      test_cp_unalnsrc(a1, a1);
+      for (int i=0; i<UNALIGN_OFF; i++) {
+        errn += verify("test_cp_unalnsrc_overlap: a1", i, a1.get(i), -1);
+      }
+      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+        int v = i%UNALIGN_OFF;
+        errn += verify("test_cp_unalnsrc_overlap: a1", i, a1.get(i), v);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1.lazySet(i, -1);
+      }
+      test_2ci_unaln(a1, a1);
+      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+        errn += verify("test_2ci_unaln_overlap: a1", i, a1.get(i), -103);
+      }
+      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2ci_unaln_overlap: a1", i, a1.get(i), -123);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1.lazySet(i, -1);
+      }
+      test_2vi_unaln(a1, a1, 123, 103);
+      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+        errn += verify("test_2vi_unaln_overlap: a1", i, a1.get(i), 123);
+      }
+      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2vi_unaln_overlap: a1", i, a1.get(i), 103);
+      }
+
+    }
+
+    if (errn > 0 || test_only)
+      return errn;
+
+    // Initialize
+    for (int i=0; i<ARRLEN; i++) {
+      a1.lazySet(i, -1);
+      a2.lazySet(i, -1);
+    }
+    System.out.println("Time");
+    long start, end;
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_ci(a1);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_ci: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_vi(a2, 123, -1);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_vi: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_ci_neg(a1, 123);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_ci_neg: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_vi_neg(a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_vi_neg: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_neg(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_neg: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_neg(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_neg: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_neg(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_neg: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_ci_oppos(a1, 123);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_ci_oppos: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_vi_oppos(a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_vi_oppos: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_oppos(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_oppos: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_oppos(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_oppos: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_oppos(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_oppos: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_ci_off(a1, 123);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_ci_off: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_vi_off(a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_vi_off: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_off(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_off: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_off(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_off: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_off(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_off: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_ci_inv(a1, OFFSET, 123);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_ci_inv: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_vi_inv(a2, 123, OFFSET, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_vi_inv: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_inv(a1, a2, OFFSET);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_inv: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_inv(a1, a2, OFFSET);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_inv: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_inv(a1, a2, 123, 103, OFFSET);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_inv: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_ci_scl(a1, 123);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_ci_scl: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_vi_scl(a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_vi_scl: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_scl(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_scl: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_scl(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_scl: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_scl(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_scl: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_alndst(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_alndst: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_alnsrc(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_alnsrc: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_aln(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_aln: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_aln(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_aln: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_unalndst(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_unalndst: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_unalnsrc(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_unalnsrc: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_unaln(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_unaln: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_unaln(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_unaln: " + (end - start));
+
+    return errn;
+  }
+
+  static void test_ci(AtomicIntegerArray a) {
+    for (int i = 0; i < ARRLEN; i+=1) {
+      a.lazySet(i, -123);
+    }
+  }
+  static void test_vi(AtomicIntegerArray a, int b, int old) {
+    for (int i = 0; i < ARRLEN; i+=1) {
+      a.lazySet(i, b);
+    }
+  }
+  static void test_cp(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = 0; i < ARRLEN; i+=1) {
+      a.lazySet(i, b.get(i));
+    }
+  }
+  static void test_2ci(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = 0; i < ARRLEN; i+=1) {
+      a.lazySet(i, -123);
+      b.lazySet(i, -103);
+    }
+  }
+  static void test_2vi(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
+    for (int i = 0; i < ARRLEN; i+=1) {
+      a.lazySet(i, c);
+      b.lazySet(i, d);
+    }
+  }
+  static void test_ci_neg(AtomicIntegerArray a, int old) {
+    for (int i = ARRLEN-1; i >= 0; i-=1) {
+      a.lazySet(i,-123);
+    }
+  }
+  static void test_vi_neg(AtomicIntegerArray a, int b, int old) {
+    for (int i = ARRLEN-1; i >= 0; i-=1) {
+      a.lazySet(i, b);
+    }
+  }
+  static void test_cp_neg(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = ARRLEN-1; i >= 0; i-=1) {
+      a.lazySet(i, b.get(i));
+    }
+  }
+  static void test_2ci_neg(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = ARRLEN-1; i >= 0; i-=1) {
+      a.lazySet(i, -123);
+      b.lazySet(i, -103);
+    }
+  }
+  static void test_2vi_neg(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
+    for (int i = ARRLEN-1; i >= 0; i-=1) {
+      a.lazySet(i, c);
+      b.lazySet(i, d);
+    }
+  }
+  static void test_ci_oppos(AtomicIntegerArray a, int old) {
+    int limit = ARRLEN-1;
+    for (int i = 0; i < ARRLEN; i+=1) {
+      a.lazySet((limit-i), -123);
+    }
+  }
+  static void test_vi_oppos(AtomicIntegerArray a, int b, int old) {
+    int limit = ARRLEN-1;
+    for (int i = limit; i >= 0; i-=1) {
+      a.lazySet((limit-i), b);
+    }
+  }
+  static void test_cp_oppos(AtomicIntegerArray a, AtomicIntegerArray b) {
+    int limit = ARRLEN-1;
+    for (int i = 0; i < ARRLEN; i+=1) {
+      a.lazySet(i, b.get(limit-i));
+    }
+  }
+  static void test_2ci_oppos(AtomicIntegerArray a, AtomicIntegerArray b) {
+    int limit = ARRLEN-1;
+    for (int i = 0; i < ARRLEN; i+=1) {
+      a.lazySet((limit-i), -123);
+      b.lazySet(i, -103);
+    }
+  }
+  static void test_2vi_oppos(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
+    int limit = ARRLEN-1;
+    for (int i = limit; i >= 0; i-=1) {
+      a.lazySet(i, c);
+      b.lazySet((limit-i), d);
+    }
+  }
+  static void test_ci_off(AtomicIntegerArray a, int old) {
+    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
+      a.lazySet((i+OFFSET), -123);
+    }
+  }
+  static void test_vi_off(AtomicIntegerArray a, int b, int old) {
+    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
+      a.lazySet((i+OFFSET), b);
+    }
+  }
+  static void test_cp_off(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
+      a.lazySet((i+OFFSET), b.get(i+OFFSET));
+    }
+  }
+  static void test_2ci_off(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
+      a.lazySet((i+OFFSET), -123);
+      b.lazySet((i+OFFSET), -103);
+    }
+  }
+  static void test_2vi_off(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
+    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
+      a.lazySet((i+OFFSET), c);
+      b.lazySet((i+OFFSET), d);
+    }
+  }
+  static void test_ci_inv(AtomicIntegerArray a, int k, int old) {
+    for (int i = 0; i < ARRLEN-k; i+=1) {
+      a.lazySet((i+k),-123);
+    }
+  }
+  static void test_vi_inv(AtomicIntegerArray a, int b, int k, int old) {
+    for (int i = 0; i < ARRLEN-k; i+=1) {
+      a.lazySet((i+k), b);
+    }
+  }
+  static void test_cp_inv(AtomicIntegerArray a, AtomicIntegerArray b, int k) {
+    for (int i = 0; i < ARRLEN-k; i+=1) {
+      a.lazySet((i+k), b.get(i+k));
+    }
+  }
+  static void test_2ci_inv(AtomicIntegerArray a, AtomicIntegerArray b, int k) {
+    for (int i = 0; i < ARRLEN-k; i+=1) {
+      a.lazySet((i+k), -123);
+      b.lazySet((i+k), -103);
+    }
+  }
+  static void test_2vi_inv(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d, int k) {
+    for (int i = 0; i < ARRLEN-k; i+=1) {
+      a.lazySet((i+k), c);
+      b.lazySet((i+k), d);
+    }
+  }
+  static void test_ci_scl(AtomicIntegerArray a, int old) {
+    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
+      a.lazySet((i*SCALE), -123);
+    }
+  }
+  static void test_vi_scl(AtomicIntegerArray a, int b, int old) {
+    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
+      a.lazySet((i*SCALE), b);
+    }
+  }
+  static void test_cp_scl(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
+      a.lazySet((i*SCALE), b.get(i*SCALE));
+    }
+  }
+  static void test_2ci_scl(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
+      a.lazySet((i*SCALE), -123);
+      b.lazySet((i*SCALE), -103);
+    }
+  }
+  static void test_2vi_scl(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
+    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
+      a.lazySet((i*SCALE), c);
+      b.lazySet((i*SCALE), d);
+    }
+  }
+  static void test_cp_alndst(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
+      a.lazySet((i+ALIGN_OFF), b.get(i));
+    }
+  }
+  static void test_cp_alnsrc(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
+      a.lazySet(i, b.get(i+ALIGN_OFF));
+    }
+  }
+  static void test_2ci_aln(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
+      a.lazySet((i+ALIGN_OFF), -123);
+      b.lazySet(i, -103);
+    }
+  }
+  static void test_2vi_aln(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
+    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
+      a.lazySet(i, c);
+      b.lazySet((i+ALIGN_OFF), d);
+    }
+  }
+  static void test_cp_unalndst(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
+      a.lazySet((i+UNALIGN_OFF), b.get(i));
+    }
+  }
+  static void test_cp_unalnsrc(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
+      a.lazySet(i, b.get(i+UNALIGN_OFF));
+    }
+  }
+  static void test_2ci_unaln(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
+      a.lazySet((i+UNALIGN_OFF), -123);
+      b.lazySet(i, -103);
+    }
+  }
+  static void test_2vi_unaln(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
+    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
+      a.lazySet(i, c);
+      b.lazySet((i+UNALIGN_OFF), d);
+    }
+  }
+
+  static int verify(String text, int i, int elem, int val) {
+    if (elem != val) {
+      System.err.println(text + "[" + i + "] = " + elem + " != " + val);
+      return 1;
+    }
+    return 0;
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compiler/8004867/TestIntAtomicVolatile.java	Thu Feb 28 10:45:18 2013 -0800
@@ -0,0 +1,969 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+/**
+ * @test
+ * @bug 8004867
+ * @summary VM crashing with assert "share/vm/opto/node.hpp:357 - assert(i < _max) failed: oob"
+ *
+ * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:-OptimizeFill TestIntAtomicVolatile
+ * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:+OptimizeFill TestIntAtomicVolatile
+ */
+
+import java.util.concurrent.atomic.AtomicIntegerArray;
+
+public class TestIntAtomicVolatile {
+  private static final int ARRLEN = 97;
+  private static final int ITERS  = 11000;
+  private static final int OFFSET = 3;
+  private static final int SCALE = 2;
+  private static final int ALIGN_OFF = 8;
+  private static final int UNALIGN_OFF = 5;
+
+  public static void main(String args[]) {
+    System.out.println("Testing Integer array atomic volatile operations");
+    int errn = test(false);
+    if (errn > 0) {
+      System.err.println("FAILED: " + errn + " errors");
+      System.exit(97);
+    }
+    System.out.println("PASSED");
+  }
+
+  static int test(boolean test_only) {
+    AtomicIntegerArray a1 = new AtomicIntegerArray(ARRLEN);
+    AtomicIntegerArray a2 = new AtomicIntegerArray(ARRLEN);
+    // Initialize
+    for (int i=0; i<ARRLEN; i++) {
+      a1.set(i, -1);
+      a2.set(i, -1);
+    }
+    System.out.println("Warmup");
+    for (int i=0; i<ITERS; i++) {
+      test_ci(a1);
+      test_vi(a2, 123, -1);
+      test_cp(a1, a2);
+      test_2ci(a1, a2);
+      test_2vi(a1, a2, 123, 103);
+      test_ci_neg(a1, 123);
+      test_vi_neg(a2, 123, 103);
+      test_cp_neg(a1, a2);
+      test_2ci_neg(a1, a2);
+      test_2vi_neg(a1, a2, 123, 103);
+      test_ci_oppos(a1, 123);
+      test_vi_oppos(a2, 123, 103);
+      test_cp_oppos(a1, a2);
+      test_2ci_oppos(a1, a2);
+      test_2vi_oppos(a1, a2, 123, 103);
+      test_ci_off(a1, 123);
+      test_vi_off(a2, 123, 103);
+      test_cp_off(a1, a2);
+      test_2ci_off(a1, a2);
+      test_2vi_off(a1, a2, 123, 103);
+      test_ci_inv(a1, OFFSET, 123);
+      test_vi_inv(a2, 123, OFFSET, 103);
+      test_cp_inv(a1, a2, OFFSET);
+      test_2ci_inv(a1, a2, OFFSET);
+      test_2vi_inv(a1, a2, 123, 103, OFFSET);
+      test_ci_scl(a1, 123);
+      test_vi_scl(a2, 123, 103);
+      test_cp_scl(a1, a2);
+      test_2ci_scl(a1, a2);
+      test_2vi_scl(a1, a2, 123, 103);
+      test_cp_alndst(a1, a2);
+      test_cp_alnsrc(a1, a2);
+      test_2ci_aln(a1, a2);
+      test_2vi_aln(a1, a2, 123, 103);
+      test_cp_unalndst(a1, a2);
+      test_cp_unalnsrc(a1, a2);
+      test_2ci_unaln(a1, a2);
+      test_2vi_unaln(a1, a2, 123, 103);
+    }
+    // Initialize
+    for (int i=0; i<ARRLEN; i++) {
+      a1.set(i, -1);
+      a2.set(i, -1);
+    }
+    // Test and verify results
+    System.out.println("Verification");
+    int errn = 0;
+    {
+      test_ci(a1);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_ci: a1", i, a1.get(i), -123);
+      }
+      test_vi(a2, 123, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_vi: a2", i, a2.get(i), 123);
+      }
+      test_cp(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_cp: a1", i, a1.get(i), 123);
+      }
+      test_2ci(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_2ci: a1", i, a1.get(i), -123);
+        errn += verify("test_2ci: a2", i, a2.get(i), -103);
+      }
+      test_2vi(a1, a2, 123, 103);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_2vi: a1", i, a1.get(i), 123);
+        errn += verify("test_2vi: a2", i, a2.get(i), 103);
+      }
+      // Reset for negative stride
+      for (int i=0; i<ARRLEN; i++) {
+        a1.set(i, -1);
+        a2.set(i, -1);
+      }
+      test_ci_neg(a1, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_ci_neg: a1", i, a1.get(i), -123);
+      }
+      test_vi_neg(a2, 123, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_vi_neg: a2", i, a2.get(i), 123);
+      }
+      test_cp_neg(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_cp_neg: a1", i, a1.get(i), 123);
+      }
+      test_2ci_neg(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_2ci_neg: a1", i, a1.get(i), -123);
+        errn += verify("test_2ci_neg: a2", i, a2.get(i), -103);
+      }
+      test_2vi_neg(a1, a2, 123, 103);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_2vi_neg: a1", i, a1.get(i), 123);
+        errn += verify("test_2vi_neg: a2", i, a2.get(i), 103);
+      }
+      // Reset for opposite stride
+      for (int i=0; i<ARRLEN; i++) {
+        a1.set(i, -1);
+        a2.set(i, -1);
+      }
+      test_ci_oppos(a1, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_ci_oppos: a1", i, a1.get(i), -123);
+      }
+      test_vi_oppos(a2, 123, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_vi_oppos: a2", i, a2.get(i), 123);
+      }
+      test_cp_oppos(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_cp_oppos: a1", i, a1.get(i), 123);
+      }
+      test_2ci_oppos(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_2ci_oppos: a1", i, a1.get(i), -123);
+        errn += verify("test_2ci_oppos: a2", i, a2.get(i), -103);
+      }
+      test_2vi_oppos(a1, a2, 123, 103);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_2vi_oppos: a1", i, a1.get(i), 123);
+        errn += verify("test_2vi_oppos: a2", i, a2.get(i), 103);
+      }
+      // Reset for indexing with offset
+      for (int i=0; i<ARRLEN; i++) {
+        a1.set(i, -1);
+        a2.set(i, -1);
+      }
+      test_ci_off(a1, -1);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_ci_off: a1", i, a1.get(i), -123);
+      }
+      test_vi_off(a2, 123, -1);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_vi_off: a2", i, a2.get(i), 123);
+      }
+      test_cp_off(a1, a2);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_cp_off: a1", i, a1.get(i), 123);
+      }
+      test_2ci_off(a1, a2);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_2ci_off: a1", i, a1.get(i), -123);
+        errn += verify("test_2ci_off: a2", i, a2.get(i), -103);
+      }
+      test_2vi_off(a1, a2, 123, 103);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_2vi_off: a1", i, a1.get(i), 123);
+        errn += verify("test_2vi_off: a2", i, a2.get(i), 103);
+      }
+      for (int i=0; i<OFFSET; i++) {
+        errn += verify("test_2vi_off: a1", i, a1.get(i), -1);
+        errn += verify("test_2vi_off: a2", i, a2.get(i), -1);
+      }
+      // Reset for indexing with invariant offset
+      for (int i=0; i<ARRLEN; i++) {
+        a1.set(i, -1);
+        a2.set(i, -1);
+      }
+      test_ci_inv(a1, OFFSET, -1);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_ci_inv: a1", i, a1.get(i), -123);
+      }
+      test_vi_inv(a2, 123, OFFSET, -1);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_vi_inv: a2", i, a2.get(i), 123);
+      }
+      test_cp_inv(a1, a2, OFFSET);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_cp_inv: a1", i, a1.get(i), 123);
+      }
+      test_2ci_inv(a1, a2, OFFSET);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_2ci_inv: a1", i, a1.get(i), -123);
+        errn += verify("test_2ci_inv: a2", i, a2.get(i), -103);
+      }
+      test_2vi_inv(a1, a2, 123, 103, OFFSET);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_2vi_inv: a1", i, a1.get(i), 123);
+        errn += verify("test_2vi_inv: a2", i, a2.get(i), 103);
+      }
+      for (int i=0; i<OFFSET; i++) {
+        errn += verify("test_2vi_inv: a1", i, a1.get(i), -1);
+        errn += verify("test_2vi_inv: a2", i, a2.get(i), -1);
+      }
+      // Reset for indexing with scale
+      for (int i=0; i<ARRLEN; i++) {
+        a1.set(i, -1);
+        a2.set(i, -1);
+      }
+      test_ci_scl(a1, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        int val = (i%SCALE != 0) ? -1 : -123;
+        errn += verify("test_ci_scl: a1", i, a1.get(i), val);
+      }
+      test_vi_scl(a2, 123, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        int val = (i%SCALE != 0) ? -1 : 123;
+        errn += verify("test_vi_scl: a2", i, a2.get(i), val);
+      }
+      test_cp_scl(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        int val = (i%SCALE != 0) ? -1 : 123;
+        errn += verify("test_cp_scl: a1", i, a1.get(i), val);
+      }
+      test_2ci_scl(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        if (i%SCALE != 0) {
+          errn += verify("test_2ci_scl: a1", i, a1.get(i), -1);
+        } else if (i*SCALE < ARRLEN) {
+          errn += verify("test_2ci_scl: a1", i*SCALE, a1.get(i*SCALE), -123);
+        }
+        if (i%SCALE != 0) {
+          errn += verify("test_2ci_scl: a2", i, a2.get(i), -1);
+        } else if (i*SCALE < ARRLEN) {
+          errn += verify("test_2ci_scl: a2", i*SCALE, a2.get(i*SCALE), -103);
+        }
+      }
+      test_2vi_scl(a1, a2, 123, 103);
+      for (int i=0; i<ARRLEN; i++) {
+        if (i%SCALE != 0) {
+          errn += verify("test_2vi_scl: a1", i, a1.get(i), -1);
+        } else if (i*SCALE < ARRLEN) {
+          errn += verify("test_2vi_scl: a1", i*SCALE, a1.get(i*SCALE), 123);
+        }
+        if (i%SCALE != 0) {
+          errn += verify("test_2vi_scl: a2", i, a2.get(i), -1);
+        } else if (i*SCALE < ARRLEN) {
+          errn += verify("test_2vi_scl: a2", i*SCALE, a2.get(i*SCALE), 103);
+        }
+      }
+      // Reset for 2 arrays with relative aligned offset
+      for (int i=0; i<ARRLEN; i++) {
+        a1.set(i, -1);
+        a2.set(i, -1);
+      }
+      test_vi(a2, 123, -1);
+      test_cp_alndst(a1, a2);
+      for (int i=0; i<ALIGN_OFF; i++) {
+        errn += verify("test_cp_alndst: a1", i, a1.get(i), -1);
+      }
+      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_cp_alndst: a1", i, a1.get(i), 123);
+      }
+      for (int i=0; i<ALIGN_OFF; i++) {
+        a1.set(i, 123);
+      }
+      test_vi(a2, -123, 123);
+      test_cp_alnsrc(a1, a2);
+      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+        errn += verify("test_cp_alnsrc: a1", i, a1.get(i), -123);
+      }
+      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_cp_alnsrc: a1", i, a1.get(i), 123);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1.set(i, -1);
+        a2.set(i, -1);
+      }
+      test_2ci_aln(a1, a2);
+      for (int i=0; i<ALIGN_OFF; i++) {
+        errn += verify("test_2ci_aln: a1", i, a1.get(i), -1);
+      }
+      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2ci_aln: a1", i, a1.get(i), -123);
+      }
+      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+        errn += verify("test_2ci_aln: a2", i, a2.get(i), -103);
+      }
+      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2ci_aln: a2", i, a2.get(i), -1);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1.set(i, -1);
+        a2.set(i, -1);
+      }
+      test_2vi_aln(a1, a2, 123, 103);
+      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+        errn += verify("test_2vi_aln: a1", i, a1.get(i), 123);
+      }
+      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2vi_aln: a1", i, a1.get(i), -1);
+      }
+      for (int i=0; i<ALIGN_OFF; i++) {
+        errn += verify("test_2vi_aln: a2", i, a2.get(i), -1);
+      }
+      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2vi_aln: a2", i, a2.get(i), 103);
+      }
+
+      // Reset for 2 arrays with relative unaligned offset
+      for (int i=0; i<ARRLEN; i++) {
+        a1.set(i, -1);
+        a2.set(i, -1);
+      }
+      test_vi(a2, 123, -1);
+      test_cp_unalndst(a1, a2);
+      for (int i=0; i<UNALIGN_OFF; i++) {
+        errn += verify("test_cp_unalndst: a1", i, a1.get(i), -1);
+      }
+      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_cp_unalndst: a1", i, a1.get(i), 123);
+      }
+      test_vi(a2, -123, 123);
+      test_cp_unalnsrc(a1, a2);
+      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+        errn += verify("test_cp_unalnsrc: a1", i, a1.get(i), -123);
+      }
+      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_cp_unalnsrc: a1", i, a1.get(i), 123);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1.set(i, -1);
+        a2.set(i, -1);
+      }
+      test_2ci_unaln(a1, a2);
+      for (int i=0; i<UNALIGN_OFF; i++) {
+        errn += verify("test_2ci_unaln: a1", i, a1.get(i), -1);
+      }
+      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2ci_unaln: a1", i, a1.get(i), -123);
+      }
+      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+        errn += verify("test_2ci_unaln: a2", i, a2.get(i), -103);
+      }
+      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2ci_unaln: a2", i, a2.get(i), -1);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1.set(i, -1);
+        a2.set(i, -1);
+      }
+      test_2vi_unaln(a1, a2, 123, 103);
+      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+        errn += verify("test_2vi_unaln: a1", i, a1.get(i), 123);
+      }
+      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2vi_unaln: a1", i, a1.get(i), -1);
+      }
+      for (int i=0; i<UNALIGN_OFF; i++) {
+        errn += verify("test_2vi_unaln: a2", i, a2.get(i), -1);
+      }
+      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2vi_unaln: a2", i, a2.get(i), 103);
+      }
+
+      // Reset for aligned overlap initialization
+      for (int i=0; i<ALIGN_OFF; i++) {
+        a1.set(i, i);
+      }
+      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+        a1.set(i, -1);
+      }
+      test_cp_alndst(a1, a1);
+      for (int i=0; i<ARRLEN; i++) {
+        int v = i%ALIGN_OFF;
+        errn += verify("test_cp_alndst_overlap: a1", i, a1.get(i), v);
+      }
+      for (int i=0; i<ALIGN_OFF; i++) {
+        a1.set((i+ALIGN_OFF), -1);
+      }
+      test_cp_alnsrc(a1, a1);
+      for (int i=0; i<ALIGN_OFF; i++) {
+        errn += verify("test_cp_alnsrc_overlap: a1", i, a1.get(i), -1);
+      }
+      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+        int v = i%ALIGN_OFF;
+        errn += verify("test_cp_alnsrc_overlap: a1", i, a1.get(i), v);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1.set(i, -1);
+      }
+      test_2ci_aln(a1, a1);
+      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+        errn += verify("test_2ci_aln_overlap: a1", i, a1.get(i), -103);
+      }
+      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2ci_aln_overlap: a1", i, a1.get(i), -123);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1.set(i, -1);
+      }
+      test_2vi_aln(a1, a1, 123, 103);
+      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+        errn += verify("test_2vi_aln_overlap: a1", i, a1.get(i), 123);
+      }
+      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2vi_aln_overlap: a1", i, a1.get(i), 103);
+      }
+
+      // Reset for unaligned overlap initialization
+      for (int i=0; i<UNALIGN_OFF; i++) {
+        a1.set(i, i);
+      }
+      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+        a1.set(i, -1);
+      }
+      test_cp_unalndst(a1, a1);
+      for (int i=0; i<ARRLEN; i++) {
+        int v = i%UNALIGN_OFF;
+        errn += verify("test_cp_unalndst_overlap: a1", i, a1.get(i), v);
+      }
+      for (int i=0; i<UNALIGN_OFF; i++) {
+        a1.set((i+UNALIGN_OFF), -1);
+      }
+      test_cp_unalnsrc(a1, a1);
+      for (int i=0; i<UNALIGN_OFF; i++) {
+        errn += verify("test_cp_unalnsrc_overlap: a1", i, a1.get(i), -1);
+      }
+      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+        int v = i%UNALIGN_OFF;
+        errn += verify("test_cp_unalnsrc_overlap: a1", i, a1.get(i), v);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1.set(i, -1);
+      }
+      test_2ci_unaln(a1, a1);
+      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+        errn += verify("test_2ci_unaln_overlap: a1", i, a1.get(i), -103);
+      }
+      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2ci_unaln_overlap: a1", i, a1.get(i), -123);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1.set(i, -1);
+      }
+      test_2vi_unaln(a1, a1, 123, 103);
+      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+        errn += verify("test_2vi_unaln_overlap: a1", i, a1.get(i), 123);
+      }
+      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2vi_unaln_overlap: a1", i, a1.get(i), 103);
+      }
+
+    }
+
+    if (errn > 0 || test_only)
+      return errn;
+
+    // Initialize
+    for (int i=0; i<ARRLEN; i++) {
+      a1.set(i, -1);
+      a2.set(i, -1);
+    }
+    System.out.println("Time");
+    long start, end;
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_ci(a1);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_ci: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_vi(a2, 123, -1);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_vi: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_ci_neg(a1, 123);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_ci_neg: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_vi_neg(a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_vi_neg: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_neg(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_neg: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_neg(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_neg: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_neg(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_neg: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_ci_oppos(a1, 123);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_ci_oppos: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_vi_oppos(a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_vi_oppos: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_oppos(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_oppos: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_oppos(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_oppos: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_oppos(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_oppos: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_ci_off(a1, 123);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_ci_off: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_vi_off(a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_vi_off: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_off(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_off: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_off(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_off: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_off(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_off: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_ci_inv(a1, OFFSET, 123);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_ci_inv: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_vi_inv(a2, 123, OFFSET, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_vi_inv: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_inv(a1, a2, OFFSET);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_inv: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_inv(a1, a2, OFFSET);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_inv: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_inv(a1, a2, 123, 103, OFFSET);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_inv: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_ci_scl(a1, 123);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_ci_scl: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_vi_scl(a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_vi_scl: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_scl(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_scl: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_scl(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_scl: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_scl(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_scl: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_alndst(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_alndst: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_alnsrc(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_alnsrc: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_aln(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_aln: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_aln(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_aln: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_unalndst(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_unalndst: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_unalnsrc(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_unalnsrc: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_unaln(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_unaln: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_unaln(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_unaln: " + (end - start));
+
+    return errn;
+  }
+
+  static void test_ci(AtomicIntegerArray a) {
+    for (int i = 0; i < ARRLEN; i+=1) {
+      a.set(i, -123);
+    }
+  }
+  static void test_vi(AtomicIntegerArray a, int b, int old) {
+    for (int i = 0; i < ARRLEN; i+=1) {
+      a.set(i, b);
+    }
+  }
+  static void test_cp(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = 0; i < ARRLEN; i+=1) {
+      a.set(i, b.get(i));
+    }
+  }
+  static void test_2ci(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = 0; i < ARRLEN; i+=1) {
+      a.set(i, -123);
+      b.set(i, -103);
+    }
+  }
+  static void test_2vi(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
+    for (int i = 0; i < ARRLEN; i+=1) {
+      a.set(i, c);
+      b.set(i, d);
+    }
+  }
+  static void test_ci_neg(AtomicIntegerArray a, int old) {
+    for (int i = ARRLEN-1; i >= 0; i-=1) {
+      a.set(i,-123);
+    }
+  }
+  static void test_vi_neg(AtomicIntegerArray a, int b, int old) {
+    for (int i = ARRLEN-1; i >= 0; i-=1) {
+      a.set(i, b);
+    }
+  }
+  static void test_cp_neg(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = ARRLEN-1; i >= 0; i-=1) {
+      a.set(i, b.get(i));
+    }
+  }
+  static void test_2ci_neg(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = ARRLEN-1; i >= 0; i-=1) {
+      a.set(i, -123);
+      b.set(i, -103);
+    }
+  }
+  static void test_2vi_neg(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
+    for (int i = ARRLEN-1; i >= 0; i-=1) {
+      a.set(i, c);
+      b.set(i, d);
+    }
+  }
+  static void test_ci_oppos(AtomicIntegerArray a, int old) {
+    int limit = ARRLEN-1;
+    for (int i = 0; i < ARRLEN; i+=1) {
+      a.set((limit-i), -123);
+    }
+  }
+  static void test_vi_oppos(AtomicIntegerArray a, int b, int old) {
+    int limit = ARRLEN-1;
+    for (int i = limit; i >= 0; i-=1) {
+      a.set((limit-i), b);
+    }
+  }
+  static void test_cp_oppos(AtomicIntegerArray a, AtomicIntegerArray b) {
+    int limit = ARRLEN-1;
+    for (int i = 0; i < ARRLEN; i+=1) {
+      a.set(i, b.get(limit-i));
+    }
+  }
+  static void test_2ci_oppos(AtomicIntegerArray a, AtomicIntegerArray b) {
+    int limit = ARRLEN-1;
+    for (int i = 0; i < ARRLEN; i+=1) {
+      a.set((limit-i), -123);
+      b.set(i, -103);
+    }
+  }
+  static void test_2vi_oppos(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
+    int limit = ARRLEN-1;
+    for (int i = limit; i >= 0; i-=1) {
+      a.set(i, c);
+      b.set((limit-i), d);
+    }
+  }
+  static void test_ci_off(AtomicIntegerArray a, int old) {
+    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
+      a.set((i+OFFSET), -123);
+    }
+  }
+  static void test_vi_off(AtomicIntegerArray a, int b, int old) {
+    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
+      a.set((i+OFFSET), b);
+    }
+  }
+  static void test_cp_off(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
+      a.set((i+OFFSET), b.get(i+OFFSET));
+    }
+  }
+  static void test_2ci_off(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
+      a.set((i+OFFSET), -123);
+      b.set((i+OFFSET), -103);
+    }
+  }
+  static void test_2vi_off(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
+    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
+      a.set((i+OFFSET), c);
+      b.set((i+OFFSET), d);
+    }
+  }
+  static void test_ci_inv(AtomicIntegerArray a, int k, int old) {
+    for (int i = 0; i < ARRLEN-k; i+=1) {
+      a.set((i+k),-123);
+    }
+  }
+  static void test_vi_inv(AtomicIntegerArray a, int b, int k, int old) {
+    for (int i = 0; i < ARRLEN-k; i+=1) {
+      a.set((i+k), b);
+    }
+  }
+  static void test_cp_inv(AtomicIntegerArray a, AtomicIntegerArray b, int k) {
+    for (int i = 0; i < ARRLEN-k; i+=1) {
+      a.set((i+k), b.get(i+k));
+    }
+  }
+  static void test_2ci_inv(AtomicIntegerArray a, AtomicIntegerArray b, int k) {
+    for (int i = 0; i < ARRLEN-k; i+=1) {
+      a.set((i+k), -123);
+      b.set((i+k), -103);
+    }
+  }
+  static void test_2vi_inv(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d, int k) {
+    for (int i = 0; i < ARRLEN-k; i+=1) {
+      a.set((i+k), c);
+      b.set((i+k), d);
+    }
+  }
+  static void test_ci_scl(AtomicIntegerArray a, int old) {
+    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
+      a.set((i*SCALE), -123);
+    }
+  }
+  static void test_vi_scl(AtomicIntegerArray a, int b, int old) {
+    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
+      a.set((i*SCALE), b);
+    }
+  }
+  static void test_cp_scl(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
+      a.set((i*SCALE), b.get(i*SCALE));
+    }
+  }
+  static void test_2ci_scl(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
+      a.set((i*SCALE), -123);
+      b.set((i*SCALE), -103);
+    }
+  }
+  static void test_2vi_scl(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
+    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
+      a.set((i*SCALE), c);
+      b.set((i*SCALE), d);
+    }
+  }
+  static void test_cp_alndst(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
+      a.set((i+ALIGN_OFF), b.get(i));
+    }
+  }
+  static void test_cp_alnsrc(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
+      a.set(i, b.get(i+ALIGN_OFF));
+    }
+  }
+  static void test_2ci_aln(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
+      a.set((i+ALIGN_OFF), -123);
+      b.set(i, -103);
+    }
+  }
+  static void test_2vi_aln(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
+    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
+      a.set(i, c);
+      b.set((i+ALIGN_OFF), d);
+    }
+  }
+  static void test_cp_unalndst(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
+      a.set((i+UNALIGN_OFF), b.get(i));
+    }
+  }
+  static void test_cp_unalnsrc(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
+      a.set(i, b.get(i+UNALIGN_OFF));
+    }
+  }
+  static void test_2ci_unaln(AtomicIntegerArray a, AtomicIntegerArray b) {
+    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
+      a.set((i+UNALIGN_OFF), -123);
+      b.set(i, -103);
+    }
+  }
+  static void test_2vi_unaln(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
+    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
+      a.set(i, c);
+      b.set((i+UNALIGN_OFF), d);
+    }
+  }
+
+  static int verify(String text, int i, int elem, int val) {
+    if (elem != val) {
+      System.err.println(text + "[" + i + "] = " + elem + " != " + val);
+      return 1;
+    }
+    return 0;
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compiler/8004867/TestIntUnsafeCAS.java	Thu Feb 28 10:45:18 2013 -0800
@@ -0,0 +1,998 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+/**
+ * @test
+ * @bug 8004867
+ * @summary VM crashing with assert "share/vm/opto/node.hpp:357 - assert(i < _max) failed: oob"
+ *
+ * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:-OptimizeFill TestIntUnsafeCAS
+ * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:+OptimizeFill TestIntUnsafeCAS
+ */
+
+import sun.misc.Unsafe;
+import java.lang.reflect.*;
+
+public class TestIntUnsafeCAS {
+  private static final int ARRLEN = 97;
+  private static final int ITERS  = 11000;
+  private static final int OFFSET = 3;
+  private static final int SCALE = 2;
+  private static final int ALIGN_OFF = 8;
+  private static final int UNALIGN_OFF = 5;
+
+  private static final Unsafe unsafe;
+  private static final int BASE;
+  static {
+    try {
+      Class c = TestIntUnsafeCAS.class.getClassLoader().loadClass("sun.misc.Unsafe");
+      Field f = c.getDeclaredField("theUnsafe");
+      f.setAccessible(true);
+      unsafe = (Unsafe)f.get(c);
+      BASE = unsafe.arrayBaseOffset(int[].class);
+    } catch (Exception e) {
+      InternalError err = new InternalError();
+      err.initCause(e);
+      throw err;
+    }
+  }
+
+  public static void main(String args[]) {
+    System.out.println("Testing Integer array unsafe CAS operations");
+    int errn = test(false);
+    if (errn > 0) {
+      System.err.println("FAILED: " + errn + " errors");
+      System.exit(97);
+    }
+    System.out.println("PASSED");
+  }
+
+  static int test(boolean test_only) {
+    int[] a1 = new int[ARRLEN];
+    int[] a2 = new int[ARRLEN];
+    // Initialize
+    for (int i=0; i<ARRLEN; i++) {
+      a1[i] = -1;
+      a2[i] = -1;
+    }
+    System.out.println("Warmup");
+    for (int i=0; i<ITERS; i++) {
+      test_ci(a1);
+      test_vi(a2, 123, -1);
+      test_cp(a1, a2);
+      test_2ci(a1, a2);
+      test_2vi(a1, a2, 123, 103);
+      test_ci_neg(a1, 123);
+      test_vi_neg(a2, 123, 103);
+      test_cp_neg(a1, a2);
+      test_2ci_neg(a1, a2);
+      test_2vi_neg(a1, a2, 123, 103);
+      test_ci_oppos(a1, 123);
+      test_vi_oppos(a2, 123, 103);
+      test_cp_oppos(a1, a2);
+      test_2ci_oppos(a1, a2);
+      test_2vi_oppos(a1, a2, 123, 103);
+      test_ci_off(a1, 123);
+      test_vi_off(a2, 123, 103);
+      test_cp_off(a1, a2);
+      test_2ci_off(a1, a2);
+      test_2vi_off(a1, a2, 123, 103);
+      test_ci_inv(a1, OFFSET, 123);
+      test_vi_inv(a2, 123, OFFSET, 103);
+      test_cp_inv(a1, a2, OFFSET);
+      test_2ci_inv(a1, a2, OFFSET);
+      test_2vi_inv(a1, a2, 123, 103, OFFSET);
+      test_ci_scl(a1, 123);
+      test_vi_scl(a2, 123, 103);
+      test_cp_scl(a1, a2);
+      test_2ci_scl(a1, a2);
+      test_2vi_scl(a1, a2, 123, 103);
+      test_cp_alndst(a1, a2);
+      test_cp_alnsrc(a1, a2);
+      test_2ci_aln(a1, a2);
+      test_2vi_aln(a1, a2, 123, 103);
+      test_cp_unalndst(a1, a2);
+      test_cp_unalnsrc(a1, a2);
+      test_2ci_unaln(a1, a2);
+      test_2vi_unaln(a1, a2, 123, 103);
+    }
+    // Initialize
+    for (int i=0; i<ARRLEN; i++) {
+      a1[i] = -1;
+      a2[i] = -1;
+    }
+    // Test and verify results
+    System.out.println("Verification");
+    int errn = 0;
+    {
+      test_ci(a1);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_ci: a1", i, a1[i], -123);
+      }
+      test_vi(a2, 123, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_vi: a2", i, a2[i], 123);
+      }
+      test_cp(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_cp: a1", i, a1[i], 123);
+      }
+      test_2ci(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_2ci: a1", i, a1[i], -123);
+        errn += verify("test_2ci: a2", i, a2[i], -103);
+      }
+      test_2vi(a1, a2, 123, 103);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_2vi: a1", i, a1[i], 123);
+        errn += verify("test_2vi: a2", i, a2[i], 103);
+      }
+      // Reset for negative stride
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+        a2[i] = -1;
+      }
+      test_ci_neg(a1, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_ci_neg: a1", i, a1[i], -123);
+      }
+      test_vi_neg(a2, 123, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_vi_neg: a2", i, a2[i], 123);
+      }
+      test_cp_neg(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_cp_neg: a1", i, a1[i], 123);
+      }
+      test_2ci_neg(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_2ci_neg: a1", i, a1[i], -123);
+        errn += verify("test_2ci_neg: a2", i, a2[i], -103);
+      }
+      test_2vi_neg(a1, a2, 123, 103);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_2vi_neg: a1", i, a1[i], 123);
+        errn += verify("test_2vi_neg: a2", i, a2[i], 103);
+      }
+      // Reset for opposite stride
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+        a2[i] = -1;
+      }
+      test_ci_oppos(a1, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_ci_oppos: a1", i, a1[i], -123);
+      }
+      test_vi_oppos(a2, 123, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_vi_oppos: a2", i, a2[i], 123);
+      }
+      test_cp_oppos(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_cp_oppos: a1", i, a1[i], 123);
+      }
+      test_2ci_oppos(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_2ci_oppos: a1", i, a1[i], -123);
+        errn += verify("test_2ci_oppos: a2", i, a2[i], -103);
+      }
+      test_2vi_oppos(a1, a2, 123, 103);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_2vi_oppos: a1", i, a1[i], 123);
+        errn += verify("test_2vi_oppos: a2", i, a2[i], 103);
+      }
+      // Reset for indexing with offset
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+        a2[i] = -1;
+      }
+      test_ci_off(a1, -1);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_ci_off: a1", i, a1[i], -123);
+      }
+      test_vi_off(a2, 123, -1);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_vi_off: a2", i, a2[i], 123);
+      }
+      test_cp_off(a1, a2);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_cp_off: a1", i, a1[i], 123);
+      }
+      test_2ci_off(a1, a2);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_2ci_off: a1", i, a1[i], -123);
+        errn += verify("test_2ci_off: a2", i, a2[i], -103);
+      }
+      test_2vi_off(a1, a2, 123, 103);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_2vi_off: a1", i, a1[i], 123);
+        errn += verify("test_2vi_off: a2", i, a2[i], 103);
+      }
+      for (int i=0; i<OFFSET; i++) {
+        errn += verify("test_2vi_off: a1", i, a1[i], -1);
+        errn += verify("test_2vi_off: a2", i, a2[i], -1);
+      }
+      // Reset for indexing with invariant offset
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+        a2[i] = -1;
+      }
+      test_ci_inv(a1, OFFSET, -1);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_ci_inv: a1", i, a1[i], -123);
+      }
+      test_vi_inv(a2, 123, OFFSET, -1);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_vi_inv: a2", i, a2[i], 123);
+      }
+      test_cp_inv(a1, a2, OFFSET);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_cp_inv: a1", i, a1[i], 123);
+      }
+      test_2ci_inv(a1, a2, OFFSET);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_2ci_inv: a1", i, a1[i], -123);
+        errn += verify("test_2ci_inv: a2", i, a2[i], -103);
+      }
+      test_2vi_inv(a1, a2, 123, 103, OFFSET);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_2vi_inv: a1", i, a1[i], 123);
+        errn += verify("test_2vi_inv: a2", i, a2[i], 103);
+      }
+      for (int i=0; i<OFFSET; i++) {
+        errn += verify("test_2vi_inv: a1", i, a1[i], -1);
+        errn += verify("test_2vi_inv: a2", i, a2[i], -1);
+      }
+      // Reset for indexing with scale
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+        a2[i] = -1;
+      }
+      test_ci_scl(a1, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        int val = (i%SCALE != 0) ? -1 : -123;
+        errn += verify("test_ci_scl: a1", i, a1[i], val);
+      }
+      test_vi_scl(a2, 123, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        int val = (i%SCALE != 0) ? -1 : 123;
+        errn += verify("test_vi_scl: a2", i, a2[i], val);
+      }
+      test_cp_scl(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        int val = (i%SCALE != 0) ? -1 : 123;
+        errn += verify("test_cp_scl: a1", i, a1[i], val);
+      }
+      test_2ci_scl(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        if (i%SCALE != 0) {
+          errn += verify("test_2ci_scl: a1", i, a1[i], -1);
+        } else if (i*SCALE < ARRLEN) {
+          errn += verify("test_2ci_scl: a1", i*SCALE, a1[i*SCALE], -123);
+        }
+        if (i%SCALE != 0) {
+          errn += verify("test_2ci_scl: a2", i, a2[i], -1);
+        } else if (i*SCALE < ARRLEN) {
+          errn += verify("test_2ci_scl: a2", i*SCALE, a2[i*SCALE], -103);
+        }
+      }
+      test_2vi_scl(a1, a2, 123, 103);
+      for (int i=0; i<ARRLEN; i++) {
+        if (i%SCALE != 0) {
+          errn += verify("test_2vi_scl: a1", i, a1[i], -1);
+        } else if (i*SCALE < ARRLEN) {
+          errn += verify("test_2vi_scl: a1", i*SCALE, a1[i*SCALE], 123);
+        }
+        if (i%SCALE != 0) {
+          errn += verify("test_2vi_scl: a2", i, a2[i], -1);
+        } else if (i*SCALE < ARRLEN) {
+          errn += verify("test_2vi_scl: a2", i*SCALE, a2[i*SCALE], 103);
+        }
+      }
+      // Reset for 2 arrays with relative aligned offset
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+        a2[i] = -1;
+      }
+      test_vi(a2, 123, -1);
+      test_cp_alndst(a1, a2);
+      for (int i=0; i<ALIGN_OFF; i++) {
+        errn += verify("test_cp_alndst: a1", i, a1[i], -1);
+      }
+      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_cp_alndst: a1", i, a1[i], 123);
+      }
+      for (int i=0; i<ALIGN_OFF; i++) {
+        a1[i] = 123;
+      }
+      test_vi(a2, -123, 123);
+      test_cp_alnsrc(a1, a2);
+      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+        errn += verify("test_cp_alnsrc: a1", i, a1[i], -123);
+      }
+      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_cp_alnsrc: a1", i, a1[i], 123);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+        a2[i] = -1;
+      }
+      test_2ci_aln(a1, a2);
+      for (int i=0; i<ALIGN_OFF; i++) {
+        errn += verify("test_2ci_aln: a1", i, a1[i], -1);
+      }
+      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2ci_aln: a1", i, a1[i], -123);
+      }
+      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+        errn += verify("test_2ci_aln: a2", i, a2[i], -103);
+      }
+      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2ci_aln: a2", i, a2[i], -1);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+        a2[i] = -1;
+      }
+      test_2vi_aln(a1, a2, 123, 103);
+      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+        errn += verify("test_2vi_aln: a1", i, a1[i], 123);
+      }
+      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2vi_aln: a1", i, a1[i], -1);
+      }
+      for (int i=0; i<ALIGN_OFF; i++) {
+        errn += verify("test_2vi_aln: a2", i, a2[i], -1);
+      }
+      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2vi_aln: a2", i, a2[i], 103);
+      }
+
+      // Reset for 2 arrays with relative unaligned offset
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+        a2[i] = -1;
+      }
+      test_vi(a2, 123, -1);
+      test_cp_unalndst(a1, a2);
+      for (int i=0; i<UNALIGN_OFF; i++) {
+        errn += verify("test_cp_unalndst: a1", i, a1[i], -1);
+      }
+      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_cp_unalndst: a1", i, a1[i], 123);
+      }
+      test_vi(a2, -123, 123);
+      test_cp_unalnsrc(a1, a2);
+      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+        errn += verify("test_cp_unalnsrc: a1", i, a1[i], -123);
+      }
+      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_cp_unalnsrc: a1", i, a1[i], 123);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+        a2[i] = -1;
+      }
+      test_2ci_unaln(a1, a2);
+      for (int i=0; i<UNALIGN_OFF; i++) {
+        errn += verify("test_2ci_unaln: a1", i, a1[i], -1);
+      }
+      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2ci_unaln: a1", i, a1[i], -123);
+      }
+      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+        errn += verify("test_2ci_unaln: a2", i, a2[i], -103);
+      }
+      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2ci_unaln: a2", i, a2[i], -1);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+        a2[i] = -1;
+      }
+      test_2vi_unaln(a1, a2, 123, 103);
+      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+        errn += verify("test_2vi_unaln: a1", i, a1[i], 123);
+      }
+      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2vi_unaln: a1", i, a1[i], -1);
+      }
+      for (int i=0; i<UNALIGN_OFF; i++) {
+        errn += verify("test_2vi_unaln: a2", i, a2[i], -1);
+      }
+      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2vi_unaln: a2", i, a2[i], 103);
+      }
+
+      // Reset for aligned overlap initialization
+      for (int i=0; i<ALIGN_OFF; i++) {
+        a1[i] = i;
+      }
+      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+        a1[i] = -1;
+      }
+      test_cp_alndst(a1, a1);
+      for (int i=0; i<ARRLEN; i++) {
+        int v = i%ALIGN_OFF;
+        errn += verify("test_cp_alndst_overlap: a1", i, a1[i], v);
+      }
+      for (int i=0; i<ALIGN_OFF; i++) {
+        a1[i+ALIGN_OFF] = -1;
+      }
+      test_cp_alnsrc(a1, a1);
+      for (int i=0; i<ALIGN_OFF; i++) {
+        errn += verify("test_cp_alnsrc_overlap: a1", i, a1[i], -1);
+      }
+      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+        int v = i%ALIGN_OFF;
+        errn += verify("test_cp_alnsrc_overlap: a1", i, a1[i], v);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+      }
+      test_2ci_aln(a1, a1);
+      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+        errn += verify("test_2ci_aln_overlap: a1", i, a1[i], -103);
+      }
+      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2ci_aln_overlap: a1", i, a1[i], -123);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+      }
+      test_2vi_aln(a1, a1, 123, 103);
+      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+        errn += verify("test_2vi_aln_overlap: a1", i, a1[i], 123);
+      }
+      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2vi_aln_overlap: a1", i, a1[i], 103);
+      }
+
+      // Reset for unaligned overlap initialization
+      for (int i=0; i<UNALIGN_OFF; i++) {
+        a1[i] = i;
+      }
+      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+        a1[i] = -1;
+      }
+      test_cp_unalndst(a1, a1);
+      for (int i=0; i<ARRLEN; i++) {
+        int v = i%UNALIGN_OFF;
+        errn += verify("test_cp_unalndst_overlap: a1", i, a1[i], v);
+      }
+      for (int i=0; i<UNALIGN_OFF; i++) {
+        a1[i+UNALIGN_OFF] = -1;
+      }
+      test_cp_unalnsrc(a1, a1);
+      for (int i=0; i<UNALIGN_OFF; i++) {
+        errn += verify("test_cp_unalnsrc_overlap: a1", i, a1[i], -1);
+      }
+      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+        int v = i%UNALIGN_OFF;
+        errn += verify("test_cp_unalnsrc_overlap: a1", i, a1[i], v);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+      }
+      test_2ci_unaln(a1, a1);
+      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+        errn += verify("test_2ci_unaln_overlap: a1", i, a1[i], -103);
+      }
+      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2ci_unaln_overlap: a1", i, a1[i], -123);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+      }
+      test_2vi_unaln(a1, a1, 123, 103);
+      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+        errn += verify("test_2vi_unaln_overlap: a1", i, a1[i], 123);
+      }
+      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2vi_unaln_overlap: a1", i, a1[i], 103);
+      }
+
+    }
+
+    if (errn > 0 || test_only)
+      return errn;
+
+    // Initialize
+    for (int i=0; i<ARRLEN; i++) {
+      a1[i] = -1;
+      a2[i] = -1;
+    }
+    System.out.println("Time");
+    long start, end;
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_ci(a1);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_ci: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_vi(a2, 123, -1);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_vi: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_ci_neg(a1, 123);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_ci_neg: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_vi_neg(a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_vi_neg: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_neg(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_neg: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_neg(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_neg: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_neg(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_neg: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_ci_oppos(a1, 123);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_ci_oppos: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_vi_oppos(a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_vi_oppos: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_oppos(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_oppos: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_oppos(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_oppos: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_oppos(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_oppos: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_ci_off(a1, 123);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_ci_off: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_vi_off(a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_vi_off: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_off(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_off: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_off(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_off: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_off(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_off: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_ci_inv(a1, OFFSET, 123);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_ci_inv: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_vi_inv(a2, 123, OFFSET, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_vi_inv: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_inv(a1, a2, OFFSET);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_inv: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_inv(a1, a2, OFFSET);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_inv: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_inv(a1, a2, 123, 103, OFFSET);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_inv: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_ci_scl(a1, 123);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_ci_scl: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_vi_scl(a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_vi_scl: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_scl(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_scl: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_scl(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_scl: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_scl(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_scl: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_alndst(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_alndst: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_alnsrc(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_alnsrc: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_aln(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_aln: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_aln(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_aln: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_unalndst(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_unalndst: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_unalnsrc(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_unalnsrc: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_unaln(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_unaln: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_unaln(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_unaln: " + (end - start));
+
+    return errn;
+  }
+
+  private final static long byte_offset(int i) {
+    return ((long)i << 2) + BASE;
+  }
+
+  static void test_ci(int[] a) {
+    for (int i = 0; i < ARRLEN; i+=1) {
+      unsafe.compareAndSwapInt(a, byte_offset(i), -1, -123);
+    }
+  }
+  static void test_vi(int[] a, int b, int old) {
+    for (int i = 0; i < ARRLEN; i+=1) {
+      unsafe.compareAndSwapInt(a, byte_offset(i), old, b);
+    }
+  }
+  static void test_cp(int[] a, int[] b) {
+    for (int i = 0; i < ARRLEN; i+=1) {
+      unsafe.compareAndSwapInt(a, byte_offset(i), -123, b[i]);
+    }
+  }
+  static void test_2ci(int[] a, int[] b) {
+    for (int i = 0; i < ARRLEN; i+=1) {
+      unsafe.compareAndSwapInt(a, byte_offset(i), 123, -123);
+      unsafe.compareAndSwapInt(b, byte_offset(i), 123, -103);
+    }
+  }
+  static void test_2vi(int[] a, int[] b, int c, int d) {
+    for (int i = 0; i < ARRLEN; i+=1) {
+      unsafe.compareAndSwapInt(a, byte_offset(i), -123, c);
+      unsafe.compareAndSwapInt(b, byte_offset(i), -103, d);
+    }
+  }
+  static void test_ci_neg(int[] a, int old) {
+    for (int i = ARRLEN-1; i >= 0; i-=1) {
+      unsafe.compareAndSwapInt(a, byte_offset(i), old, -123);
+    }
+  }
+  static void test_vi_neg(int[] a, int b, int old) {
+    for (int i = ARRLEN-1; i >= 0; i-=1) {
+      unsafe.compareAndSwapInt(a, byte_offset(i), old, b);
+    }
+  }
+  static void test_cp_neg(int[] a, int[] b) {
+    for (int i = ARRLEN-1; i >= 0; i-=1) {
+      unsafe.compareAndSwapInt(a, byte_offset(i), -123, b[i]);
+    }
+  }
+  static void test_2ci_neg(int[] a, int[] b) {
+    for (int i = ARRLEN-1; i >= 0; i-=1) {
+      unsafe.compareAndSwapInt(a, byte_offset(i), 123, -123);
+      unsafe.compareAndSwapInt(b, byte_offset(i), 123, -103);
+    }
+  }
+  static void test_2vi_neg(int[] a, int[] b, int c, int d) {
+    for (int i = ARRLEN-1; i >= 0; i-=1) {
+      unsafe.compareAndSwapInt(a, byte_offset(i), -123, c);
+      unsafe.compareAndSwapInt(b, byte_offset(i), -103, d);
+    }
+  }
+  static void test_ci_oppos(int[] a, int old) {
+    int limit = ARRLEN-1;
+    for (int i = 0; i < ARRLEN; i+=1) {
+      unsafe.compareAndSwapInt(a, byte_offset(limit-i), old, -123);
+    }
+  }
+  static void test_vi_oppos(int[] a, int b, int old) {
+    int limit = ARRLEN-1;
+    for (int i = limit; i >= 0; i-=1) {
+      unsafe.compareAndSwapInt(a, byte_offset(limit-i), old, b);
+    }
+  }
+  static void test_cp_oppos(int[] a, int[] b) {
+    int limit = ARRLEN-1;
+    for (int i = 0; i < ARRLEN; i+=1) {
+      unsafe.compareAndSwapInt(a, byte_offset(i), -123, b[limit-i]);
+    }
+  }
+  static void test_2ci_oppos(int[] a, int[] b) {
+    int limit = ARRLEN-1;
+    for (int i = 0; i < ARRLEN; i+=1) {
+      unsafe.compareAndSwapInt(a, byte_offset(limit-i), 123, -123);
+      unsafe.compareAndSwapInt(b, byte_offset(i), 123, -103);
+    }
+  }
+  static void test_2vi_oppos(int[] a, int[] b, int c, int d) {
+    int limit = ARRLEN-1;
+    for (int i = limit; i >= 0; i-=1) {
+      unsafe.compareAndSwapInt(a, byte_offset(i), -123, c);
+      unsafe.compareAndSwapInt(b, byte_offset(limit-i), -103, d);
+    }
+  }
+  static void test_ci_off(int[] a, int old) {
+    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
+      unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), old, -123);
+    }
+  }
+  static void test_vi_off(int[] a, int b, int old) {
+    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
+      unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), old, b);
+    }
+  }
+  static void test_cp_off(int[] a, int[] b) {
+    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
+      unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), -123, b[i+OFFSET]);
+    }
+  }
+  static void test_2ci_off(int[] a, int[] b) {
+    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
+      unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), 123, -123);
+      unsafe.compareAndSwapInt(b, byte_offset(i+OFFSET), 123, -103);
+    }
+  }
+  static void test_2vi_off(int[] a, int[] b, int c, int d) {
+    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
+      unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), -123, c);
+      unsafe.compareAndSwapInt(b, byte_offset(i+OFFSET), -103, d);
+    }
+  }
+  static void test_ci_inv(int[] a, int k, int old) {
+    for (int i = 0; i < ARRLEN-k; i+=1) {
+      unsafe.compareAndSwapInt(a, byte_offset(i+k), old, -123);
+    }
+  }
+  static void test_vi_inv(int[] a, int b, int k, int old) {
+    for (int i = 0; i < ARRLEN-k; i+=1) {
+      unsafe.compareAndSwapInt(a, byte_offset(i+k), old, b);
+    }
+  }
+  static void test_cp_inv(int[] a, int[] b, int k) {
+    for (int i = 0; i < ARRLEN-k; i+=1) {
+      unsafe.compareAndSwapInt(a, byte_offset(i+k), -123, b[i+k]);
+    }
+  }
+  static void test_2ci_inv(int[] a, int[] b, int k) {
+    for (int i = 0; i < ARRLEN-k; i+=1) {
+      unsafe.compareAndSwapInt(a, byte_offset(i+k), 123, -123);
+      unsafe.compareAndSwapInt(b, byte_offset(i+k), 123, -103);
+    }
+  }
+  static void test_2vi_inv(int[] a, int[] b, int c, int d, int k) {
+    for (int i = 0; i < ARRLEN-k; i+=1) {
+      unsafe.compareAndSwapInt(a, byte_offset(i+k), -123, c);
+      unsafe.compareAndSwapInt(b, byte_offset(i+k), -103, d);
+    }
+  }
+  static void test_ci_scl(int[] a, int old) {
+    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
+      unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), old, -123);
+    }
+  }
+  static void test_vi_scl(int[] a, int b, int old) {
+    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
+      unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), old, b);
+    }
+  }
+  static void test_cp_scl(int[] a, int[] b) {
+    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
+      unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), -123, b[i*SCALE]);
+    }
+  }
+  static void test_2ci_scl(int[] a, int[] b) {
+    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
+      unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), 123, -123);
+      unsafe.compareAndSwapInt(b, byte_offset(i*SCALE), 123, -103);
+    }
+  }
+  static void test_2vi_scl(int[] a, int[] b, int c, int d) {
+    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
+      unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), -123, c);
+      unsafe.compareAndSwapInt(b, byte_offset(i*SCALE), -103, d);
+    }
+  }
+  static void test_cp_alndst(int[] a, int[] b) {
+    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
+      unsafe.compareAndSwapInt(a, byte_offset(i+ALIGN_OFF), -1, b[i]);
+    }
+  }
+  static void test_cp_alnsrc(int[] a, int[] b) {
+    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
+      int old = unsafe.getIntVolatile(a, byte_offset(i));
+      unsafe.compareAndSwapInt(a, byte_offset(i), old, b[i+ALIGN_OFF]);
+    }
+  }
+  static void test_2ci_aln(int[] a, int[] b) {
+    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
+      unsafe.compareAndSwapInt(a, byte_offset(i+ALIGN_OFF), -1, -123);
+      int old = unsafe.getIntVolatile(b, byte_offset(i));
+      unsafe.compareAndSwapInt(b, byte_offset(i), old, -103);
+    }
+  }
+  static void test_2vi_aln(int[] a, int[] b, int c, int d) {
+    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
+      int old = unsafe.getIntVolatile(a, byte_offset(i));
+      unsafe.compareAndSwapInt(a, byte_offset(i), old, c);
+      old = unsafe.getIntVolatile(b, byte_offset(i+ALIGN_OFF));
+      unsafe.compareAndSwapInt(b, byte_offset(i+ALIGN_OFF), old, d);
+    }
+  }
+  static void test_cp_unalndst(int[] a, int[] b) {
+    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
+      unsafe.compareAndSwapInt(a, byte_offset(i+UNALIGN_OFF), -1, b[i]);
+    }
+  }
+  static void test_cp_unalnsrc(int[] a, int[] b) {
+    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
+      int old = unsafe.getIntVolatile(a, byte_offset(i));
+      unsafe.compareAndSwapInt(a, byte_offset(i), old, b[i+UNALIGN_OFF]);
+    }
+  }
+  static void test_2ci_unaln(int[] a, int[] b) {
+    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
+      unsafe.compareAndSwapInt(a, byte_offset(i+UNALIGN_OFF), -1, -123);
+      int old = unsafe.getIntVolatile(b, byte_offset(i));
+      unsafe.compareAndSwapInt(b, byte_offset(i), old, -103);
+    }
+  }
+  static void test_2vi_unaln(int[] a, int[] b, int c, int d) {
+    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
+      int old = unsafe.getIntVolatile(a, byte_offset(i));
+      unsafe.compareAndSwapInt(a, byte_offset(i), old, c);
+      old = unsafe.getIntVolatile(b, byte_offset(i+UNALIGN_OFF));
+      unsafe.compareAndSwapInt(b, byte_offset(i+UNALIGN_OFF), old, d);
+    }
+  }
+
+  static int verify(String text, int i, int elem, int val) {
+    if (elem != val) {
+      System.err.println(text + "[" + i + "] = " + elem + " != " + val);
+      return 1;
+    }
+    return 0;
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compiler/8004867/TestIntUnsafeOrdered.java	Thu Feb 28 10:45:18 2013 -0800
@@ -0,0 +1,990 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+/**
+ * @test
+ * @bug 8004867
+ * @summary VM crashing with assert "share/vm/opto/node.hpp:357 - assert(i < _max) failed: oob"
+ *
+ * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:-OptimizeFill TestIntUnsafeOrdered
+ * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:+OptimizeFill TestIntUnsafeOrdered
+ */
+
+import sun.misc.Unsafe;
+import java.lang.reflect.*;
+
+public class TestIntUnsafeOrdered {
+  private static final int ARRLEN = 97;
+  private static final int ITERS  = 11000;
+  private static final int OFFSET = 3;
+  private static final int SCALE = 2;
+  private static final int ALIGN_OFF = 8;
+  private static final int UNALIGN_OFF = 5;
+
+  private static final Unsafe unsafe;
+  private static final int BASE;
+  static {
+    try {
+      Class c = TestIntUnsafeOrdered.class.getClassLoader().loadClass("sun.misc.Unsafe");
+      Field f = c.getDeclaredField("theUnsafe");
+      f.setAccessible(true);
+      unsafe = (Unsafe)f.get(c);
+      BASE = unsafe.arrayBaseOffset(int[].class);
+    } catch (Exception e) {
+      InternalError err = new InternalError();
+      err.initCause(e);
+      throw err;
+    }
+  }
+
+  public static void main(String args[]) {
+    System.out.println("Testing Integer array unsafe ordered operations");
+    int errn = test(false);
+    if (errn > 0) {
+      System.err.println("FAILED: " + errn + " errors");
+      System.exit(97);
+    }
+    System.out.println("PASSED");
+  }
+
+  static int test(boolean test_only) {
+    int[] a1 = new int[ARRLEN];
+    int[] a2 = new int[ARRLEN];
+    // Initialize
+    for (int i=0; i<ARRLEN; i++) {
+      a1[i] = -1;
+      a2[i] = -1;
+    }
+    System.out.println("Warmup");
+    for (int i=0; i<ITERS; i++) {
+      test_ci(a1);
+      test_vi(a2, 123, -1);
+      test_cp(a1, a2);
+      test_2ci(a1, a2);
+      test_2vi(a1, a2, 123, 103);
+      test_ci_neg(a1, 123);
+      test_vi_neg(a2, 123, 103);
+      test_cp_neg(a1, a2);
+      test_2ci_neg(a1, a2);
+      test_2vi_neg(a1, a2, 123, 103);
+      test_ci_oppos(a1, 123);
+      test_vi_oppos(a2, 123, 103);
+      test_cp_oppos(a1, a2);
+      test_2ci_oppos(a1, a2);
+      test_2vi_oppos(a1, a2, 123, 103);
+      test_ci_off(a1, 123);
+      test_vi_off(a2, 123, 103);
+      test_cp_off(a1, a2);
+      test_2ci_off(a1, a2);
+      test_2vi_off(a1, a2, 123, 103);
+      test_ci_inv(a1, OFFSET, 123);
+      test_vi_inv(a2, 123, OFFSET, 103);
+      test_cp_inv(a1, a2, OFFSET);
+      test_2ci_inv(a1, a2, OFFSET);
+      test_2vi_inv(a1, a2, 123, 103, OFFSET);
+      test_ci_scl(a1, 123);
+      test_vi_scl(a2, 123, 103);
+      test_cp_scl(a1, a2);
+      test_2ci_scl(a1, a2);
+      test_2vi_scl(a1, a2, 123, 103);
+      test_cp_alndst(a1, a2);
+      test_cp_alnsrc(a1, a2);
+      test_2ci_aln(a1, a2);
+      test_2vi_aln(a1, a2, 123, 103);
+      test_cp_unalndst(a1, a2);
+      test_cp_unalnsrc(a1, a2);
+      test_2ci_unaln(a1, a2);
+      test_2vi_unaln(a1, a2, 123, 103);
+    }
+    // Initialize
+    for (int i=0; i<ARRLEN; i++) {
+      a1[i] = -1;
+      a2[i] = -1;
+    }
+    // Test and verify results
+    System.out.println("Verification");
+    int errn = 0;
+    {
+      test_ci(a1);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_ci: a1", i, a1[i], -123);
+      }
+      test_vi(a2, 123, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_vi: a2", i, a2[i], 123);
+      }
+      test_cp(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_cp: a1", i, a1[i], 123);
+      }
+      test_2ci(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_2ci: a1", i, a1[i], -123);
+        errn += verify("test_2ci: a2", i, a2[i], -103);
+      }
+      test_2vi(a1, a2, 123, 103);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_2vi: a1", i, a1[i], 123);
+        errn += verify("test_2vi: a2", i, a2[i], 103);
+      }
+      // Reset for negative stride
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+        a2[i] = -1;
+      }
+      test_ci_neg(a1, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_ci_neg: a1", i, a1[i], -123);
+      }
+      test_vi_neg(a2, 123, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_vi_neg: a2", i, a2[i], 123);
+      }
+      test_cp_neg(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_cp_neg: a1", i, a1[i], 123);
+      }
+      test_2ci_neg(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_2ci_neg: a1", i, a1[i], -123);
+        errn += verify("test_2ci_neg: a2", i, a2[i], -103);
+      }
+      test_2vi_neg(a1, a2, 123, 103);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_2vi_neg: a1", i, a1[i], 123);
+        errn += verify("test_2vi_neg: a2", i, a2[i], 103);
+      }
+      // Reset for opposite stride
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+        a2[i] = -1;
+      }
+      test_ci_oppos(a1, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_ci_oppos: a1", i, a1[i], -123);
+      }
+      test_vi_oppos(a2, 123, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_vi_oppos: a2", i, a2[i], 123);
+      }
+      test_cp_oppos(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_cp_oppos: a1", i, a1[i], 123);
+      }
+      test_2ci_oppos(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_2ci_oppos: a1", i, a1[i], -123);
+        errn += verify("test_2ci_oppos: a2", i, a2[i], -103);
+      }
+      test_2vi_oppos(a1, a2, 123, 103);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_2vi_oppos: a1", i, a1[i], 123);
+        errn += verify("test_2vi_oppos: a2", i, a2[i], 103);
+      }
+      // Reset for indexing with offset
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+        a2[i] = -1;
+      }
+      test_ci_off(a1, -1);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_ci_off: a1", i, a1[i], -123);
+      }
+      test_vi_off(a2, 123, -1);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_vi_off: a2", i, a2[i], 123);
+      }
+      test_cp_off(a1, a2);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_cp_off: a1", i, a1[i], 123);
+      }
+      test_2ci_off(a1, a2);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_2ci_off: a1", i, a1[i], -123);
+        errn += verify("test_2ci_off: a2", i, a2[i], -103);
+      }
+      test_2vi_off(a1, a2, 123, 103);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_2vi_off: a1", i, a1[i], 123);
+        errn += verify("test_2vi_off: a2", i, a2[i], 103);
+      }
+      for (int i=0; i<OFFSET; i++) {
+        errn += verify("test_2vi_off: a1", i, a1[i], -1);
+        errn += verify("test_2vi_off: a2", i, a2[i], -1);
+      }
+      // Reset for indexing with invariant offset
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+        a2[i] = -1;
+      }
+      test_ci_inv(a1, OFFSET, -1);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_ci_inv: a1", i, a1[i], -123);
+      }
+      test_vi_inv(a2, 123, OFFSET, -1);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_vi_inv: a2", i, a2[i], 123);
+      }
+      test_cp_inv(a1, a2, OFFSET);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_cp_inv: a1", i, a1[i], 123);
+      }
+      test_2ci_inv(a1, a2, OFFSET);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_2ci_inv: a1", i, a1[i], -123);
+        errn += verify("test_2ci_inv: a2", i, a2[i], -103);
+      }
+      test_2vi_inv(a1, a2, 123, 103, OFFSET);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_2vi_inv: a1", i, a1[i], 123);
+        errn += verify("test_2vi_inv: a2", i, a2[i], 103);
+      }
+      for (int i=0; i<OFFSET; i++) {
+        errn += verify("test_2vi_inv: a1", i, a1[i], -1);
+        errn += verify("test_2vi_inv: a2", i, a2[i], -1);
+      }
+      // Reset for indexing with scale
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+        a2[i] = -1;
+      }
+      test_ci_scl(a1, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        int val = (i%SCALE != 0) ? -1 : -123;
+        errn += verify("test_ci_scl: a1", i, a1[i], val);
+      }
+      test_vi_scl(a2, 123, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        int val = (i%SCALE != 0) ? -1 : 123;
+        errn += verify("test_vi_scl: a2", i, a2[i], val);
+      }
+      test_cp_scl(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        int val = (i%SCALE != 0) ? -1 : 123;
+        errn += verify("test_cp_scl: a1", i, a1[i], val);
+      }
+      test_2ci_scl(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        if (i%SCALE != 0) {
+          errn += verify("test_2ci_scl: a1", i, a1[i], -1);
+        } else if (i*SCALE < ARRLEN) {
+          errn += verify("test_2ci_scl: a1", i*SCALE, a1[i*SCALE], -123);
+        }
+        if (i%SCALE != 0) {
+          errn += verify("test_2ci_scl: a2", i, a2[i], -1);
+        } else if (i*SCALE < ARRLEN) {
+          errn += verify("test_2ci_scl: a2", i*SCALE, a2[i*SCALE], -103);
+        }
+      }
+      test_2vi_scl(a1, a2, 123, 103);
+      for (int i=0; i<ARRLEN; i++) {
+        if (i%SCALE != 0) {
+          errn += verify("test_2vi_scl: a1", i, a1[i], -1);
+        } else if (i*SCALE < ARRLEN) {
+          errn += verify("test_2vi_scl: a1", i*SCALE, a1[i*SCALE], 123);
+        }
+        if (i%SCALE != 0) {
+          errn += verify("test_2vi_scl: a2", i, a2[i], -1);
+        } else if (i*SCALE < ARRLEN) {
+          errn += verify("test_2vi_scl: a2", i*SCALE, a2[i*SCALE], 103);
+        }
+      }
+      // Reset for 2 arrays with relative aligned offset
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+        a2[i] = -1;
+      }
+      test_vi(a2, 123, -1);
+      test_cp_alndst(a1, a2);
+      for (int i=0; i<ALIGN_OFF; i++) {
+        errn += verify("test_cp_alndst: a1", i, a1[i], -1);
+      }
+      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_cp_alndst: a1", i, a1[i], 123);
+      }
+      for (int i=0; i<ALIGN_OFF; i++) {
+        a1[i] = 123;
+      }
+      test_vi(a2, -123, 123);
+      test_cp_alnsrc(a1, a2);
+      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+        errn += verify("test_cp_alnsrc: a1", i, a1[i], -123);
+      }
+      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_cp_alnsrc: a1", i, a1[i], 123);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+        a2[i] = -1;
+      }
+      test_2ci_aln(a1, a2);
+      for (int i=0; i<ALIGN_OFF; i++) {
+        errn += verify("test_2ci_aln: a1", i, a1[i], -1);
+      }
+      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2ci_aln: a1", i, a1[i], -123);
+      }
+      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+        errn += verify("test_2ci_aln: a2", i, a2[i], -103);
+      }
+      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2ci_aln: a2", i, a2[i], -1);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+        a2[i] = -1;
+      }
+      test_2vi_aln(a1, a2, 123, 103);
+      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+        errn += verify("test_2vi_aln: a1", i, a1[i], 123);
+      }
+      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2vi_aln: a1", i, a1[i], -1);
+      }
+      for (int i=0; i<ALIGN_OFF; i++) {
+        errn += verify("test_2vi_aln: a2", i, a2[i], -1);
+      }
+      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2vi_aln: a2", i, a2[i], 103);
+      }
+
+      // Reset for 2 arrays with relative unaligned offset
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+        a2[i] = -1;
+      }
+      test_vi(a2, 123, -1);
+      test_cp_unalndst(a1, a2);
+      for (int i=0; i<UNALIGN_OFF; i++) {
+        errn += verify("test_cp_unalndst: a1", i, a1[i], -1);
+      }
+      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_cp_unalndst: a1", i, a1[i], 123);
+      }
+      test_vi(a2, -123, 123);
+      test_cp_unalnsrc(a1, a2);
+      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+        errn += verify("test_cp_unalnsrc: a1", i, a1[i], -123);
+      }
+      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_cp_unalnsrc: a1", i, a1[i], 123);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+        a2[i] = -1;
+      }
+      test_2ci_unaln(a1, a2);
+      for (int i=0; i<UNALIGN_OFF; i++) {
+        errn += verify("test_2ci_unaln: a1", i, a1[i], -1);
+      }
+      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2ci_unaln: a1", i, a1[i], -123);
+      }
+      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+        errn += verify("test_2ci_unaln: a2", i, a2[i], -103);
+      }
+      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2ci_unaln: a2", i, a2[i], -1);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+        a2[i] = -1;
+      }
+      test_2vi_unaln(a1, a2, 123, 103);
+      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+        errn += verify("test_2vi_unaln: a1", i, a1[i], 123);
+      }
+      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2vi_unaln: a1", i, a1[i], -1);
+      }
+      for (int i=0; i<UNALIGN_OFF; i++) {
+        errn += verify("test_2vi_unaln: a2", i, a2[i], -1);
+      }
+      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2vi_unaln: a2", i, a2[i], 103);
+      }
+
+      // Reset for aligned overlap initialization
+      for (int i=0; i<ALIGN_OFF; i++) {
+        a1[i] = i;
+      }
+      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+        a1[i] = -1;
+      }
+      test_cp_alndst(a1, a1);
+      for (int i=0; i<ARRLEN; i++) {
+        int v = i%ALIGN_OFF;
+        errn += verify("test_cp_alndst_overlap: a1", i, a1[i], v);
+      }
+      for (int i=0; i<ALIGN_OFF; i++) {
+        a1[i+ALIGN_OFF] = -1;
+      }
+      test_cp_alnsrc(a1, a1);
+      for (int i=0; i<ALIGN_OFF; i++) {
+        errn += verify("test_cp_alnsrc_overlap: a1", i, a1[i], -1);
+      }
+      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+        int v = i%ALIGN_OFF;
+        errn += verify("test_cp_alnsrc_overlap: a1", i, a1[i], v);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+      }
+      test_2ci_aln(a1, a1);
+      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+        errn += verify("test_2ci_aln_overlap: a1", i, a1[i], -103);
+      }
+      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2ci_aln_overlap: a1", i, a1[i], -123);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+      }
+      test_2vi_aln(a1, a1, 123, 103);
+      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+        errn += verify("test_2vi_aln_overlap: a1", i, a1[i], 123);
+      }
+      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2vi_aln_overlap: a1", i, a1[i], 103);
+      }
+
+      // Reset for unaligned overlap initialization
+      for (int i=0; i<UNALIGN_OFF; i++) {
+        a1[i] = i;
+      }
+      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+        a1[i] = -1;
+      }
+      test_cp_unalndst(a1, a1);
+      for (int i=0; i<ARRLEN; i++) {
+        int v = i%UNALIGN_OFF;
+        errn += verify("test_cp_unalndst_overlap: a1", i, a1[i], v);
+      }
+      for (int i=0; i<UNALIGN_OFF; i++) {
+        a1[i+UNALIGN_OFF] = -1;
+      }
+      test_cp_unalnsrc(a1, a1);
+      for (int i=0; i<UNALIGN_OFF; i++) {
+        errn += verify("test_cp_unalnsrc_overlap: a1", i, a1[i], -1);
+      }
+      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+        int v = i%UNALIGN_OFF;
+        errn += verify("test_cp_unalnsrc_overlap: a1", i, a1[i], v);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+      }
+      test_2ci_unaln(a1, a1);
+      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+        errn += verify("test_2ci_unaln_overlap: a1", i, a1[i], -103);
+      }
+      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2ci_unaln_overlap: a1", i, a1[i], -123);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+      }
+      test_2vi_unaln(a1, a1, 123, 103);
+      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+        errn += verify("test_2vi_unaln_overlap: a1", i, a1[i], 123);
+      }
+      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2vi_unaln_overlap: a1", i, a1[i], 103);
+      }
+
+    }
+
+    if (errn > 0 || test_only)
+      return errn;
+
+    // Initialize
+    for (int i=0; i<ARRLEN; i++) {
+      a1[i] = -1;
+      a2[i] = -1;
+    }
+    System.out.println("Time");
+    long start, end;
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_ci(a1);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_ci: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_vi(a2, 123, -1);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_vi: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_ci_neg(a1, 123);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_ci_neg: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_vi_neg(a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_vi_neg: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_neg(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_neg: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_neg(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_neg: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_neg(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_neg: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_ci_oppos(a1, 123);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_ci_oppos: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_vi_oppos(a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_vi_oppos: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_oppos(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_oppos: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_oppos(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_oppos: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_oppos(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_oppos: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_ci_off(a1, 123);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_ci_off: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_vi_off(a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_vi_off: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_off(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_off: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_off(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_off: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_off(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_off: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_ci_inv(a1, OFFSET, 123);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_ci_inv: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_vi_inv(a2, 123, OFFSET, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_vi_inv: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_inv(a1, a2, OFFSET);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_inv: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_inv(a1, a2, OFFSET);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_inv: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_inv(a1, a2, 123, 103, OFFSET);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_inv: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_ci_scl(a1, 123);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_ci_scl: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_vi_scl(a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_vi_scl: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_scl(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_scl: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_scl(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_scl: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_scl(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_scl: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_alndst(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_alndst: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_alnsrc(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_alnsrc: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_aln(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_aln: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_aln(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_aln: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_unalndst(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_unalndst: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_unalnsrc(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_unalnsrc: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_unaln(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_unaln: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_unaln(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_unaln: " + (end - start));
+
+    return errn;
+  }
+
+  private final static long byte_offset(int i) {
+    return ((long)i << 2) + BASE;
+  }
+
+  static void test_ci(int[] a) {
+    for (int i = 0; i < ARRLEN; i+=1) {
+      unsafe.putOrderedInt(a, byte_offset(i), -123);
+    }
+  }
+  static void test_vi(int[] a, int b, int old) {
+    for (int i = 0; i < ARRLEN; i+=1) {
+      unsafe.putOrderedInt(a, byte_offset(i), b);
+    }
+  }
+  static void test_cp(int[] a, int[] b) {
+    for (int i = 0; i < ARRLEN; i+=1) {
+      unsafe.putOrderedInt(a, byte_offset(i), b[i]);
+    }
+  }
+  static void test_2ci(int[] a, int[] b) {
+    for (int i = 0; i < ARRLEN; i+=1) {
+      unsafe.putOrderedInt(a, byte_offset(i), -123);
+      unsafe.putOrderedInt(b, byte_offset(i), -103);
+    }
+  }
+  static void test_2vi(int[] a, int[] b, int c, int d) {
+    for (int i = 0; i < ARRLEN; i+=1) {
+      unsafe.putOrderedInt(a, byte_offset(i), c);
+      unsafe.putOrderedInt(b, byte_offset(i), d);
+    }
+  }
+  static void test_ci_neg(int[] a, int old) {
+    for (int i = ARRLEN-1; i >= 0; i-=1) {
+      unsafe.putOrderedInt(a, byte_offset(i), -123);
+    }
+  }
+  static void test_vi_neg(int[] a, int b, int old) {
+    for (int i = ARRLEN-1; i >= 0; i-=1) {
+      unsafe.putOrderedInt(a, byte_offset(i), b);
+    }
+  }
+  static void test_cp_neg(int[] a, int[] b) {
+    for (int i = ARRLEN-1; i >= 0; i-=1) {
+      unsafe.putOrderedInt(a, byte_offset(i), b[i]);
+    }
+  }
+  static void test_2ci_neg(int[] a, int[] b) {
+    for (int i = ARRLEN-1; i >= 0; i-=1) {
+      unsafe.putOrderedInt(a, byte_offset(i), -123);
+      unsafe.putOrderedInt(b, byte_offset(i), -103);
+    }
+  }
+  static void test_2vi_neg(int[] a, int[] b, int c, int d) {
+    for (int i = ARRLEN-1; i >= 0; i-=1) {
+      unsafe.putOrderedInt(a, byte_offset(i), c);
+      unsafe.putOrderedInt(b, byte_offset(i), d);
+    }
+  }
+  static void test_ci_oppos(int[] a, int old) {
+    int limit = ARRLEN-1;
+    for (int i = 0; i < ARRLEN; i+=1) {
+      unsafe.putOrderedInt(a, byte_offset(limit-i), -123);
+    }
+  }
+  static void test_vi_oppos(int[] a, int b, int old) {
+    int limit = ARRLEN-1;
+    for (int i = limit; i >= 0; i-=1) {
+      unsafe.putOrderedInt(a, byte_offset(limit-i), b);
+    }
+  }
+  static void test_cp_oppos(int[] a, int[] b) {
+    int limit = ARRLEN-1;
+    for (int i = 0; i < ARRLEN; i+=1) {
+      unsafe.putOrderedInt(a, byte_offset(i), b[limit-i]);
+    }
+  }
+  static void test_2ci_oppos(int[] a, int[] b) {
+    int limit = ARRLEN-1;
+    for (int i = 0; i < ARRLEN; i+=1) {
+      unsafe.putOrderedInt(a, byte_offset(limit-i), -123);
+      unsafe.putOrderedInt(b, byte_offset(i), -103);
+    }
+  }
+  static void test_2vi_oppos(int[] a, int[] b, int c, int d) {
+    int limit = ARRLEN-1;
+    for (int i = limit; i >= 0; i-=1) {
+      unsafe.putOrderedInt(a, byte_offset(i), c);
+      unsafe.putOrderedInt(b, byte_offset(limit-i), d);
+    }
+  }
+  static void test_ci_off(int[] a, int old) {
+    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
+      unsafe.putOrderedInt(a, byte_offset(i+OFFSET), -123);
+    }
+  }
+  static void test_vi_off(int[] a, int b, int old) {
+    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
+      unsafe.putOrderedInt(a, byte_offset(i+OFFSET), b);
+    }
+  }
+  static void test_cp_off(int[] a, int[] b) {
+    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
+      unsafe.putOrderedInt(a, byte_offset(i+OFFSET), b[i+OFFSET]);
+    }
+  }
+  static void test_2ci_off(int[] a, int[] b) {
+    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
+      unsafe.putOrderedInt(a, byte_offset(i+OFFSET), -123);
+      unsafe.putOrderedInt(b, byte_offset(i+OFFSET), -103);
+    }
+  }
+  static void test_2vi_off(int[] a, int[] b, int c, int d) {
+    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
+      unsafe.putOrderedInt(a, byte_offset(i+OFFSET), c);
+      unsafe.putOrderedInt(b, byte_offset(i+OFFSET), d);
+    }
+  }
+  static void test_ci_inv(int[] a, int k, int old) {
+    for (int i = 0; i < ARRLEN-k; i+=1) {
+      unsafe.putOrderedInt(a, byte_offset(i+k), -123);
+    }
+  }
+  static void test_vi_inv(int[] a, int b, int k, int old) {
+    for (int i = 0; i < ARRLEN-k; i+=1) {
+      unsafe.putOrderedInt(a, byte_offset(i+k), b);
+    }
+  }
+  static void test_cp_inv(int[] a, int[] b, int k) {
+    for (int i = 0; i < ARRLEN-k; i+=1) {
+      unsafe.putOrderedInt(a, byte_offset(i+k), b[i+k]);
+    }
+  }
+  static void test_2ci_inv(int[] a, int[] b, int k) {
+    for (int i = 0; i < ARRLEN-k; i+=1) {
+      unsafe.putOrderedInt(a, byte_offset(i+k), -123);
+      unsafe.putOrderedInt(b, byte_offset(i+k), -103);
+    }
+  }
+  static void test_2vi_inv(int[] a, int[] b, int c, int d, int k) {
+    for (int i = 0; i < ARRLEN-k; i+=1) {
+      unsafe.putOrderedInt(a, byte_offset(i+k), c);
+      unsafe.putOrderedInt(b, byte_offset(i+k), d);
+    }
+  }
+  static void test_ci_scl(int[] a, int old) {
+    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
+      unsafe.putOrderedInt(a, byte_offset(i*SCALE), -123);
+    }
+  }
+  static void test_vi_scl(int[] a, int b, int old) {
+    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
+      unsafe.putOrderedInt(a, byte_offset(i*SCALE), b);
+    }
+  }
+  static void test_cp_scl(int[] a, int[] b) {
+    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
+      unsafe.putOrderedInt(a, byte_offset(i*SCALE), b[i*SCALE]);
+    }
+  }
+  static void test_2ci_scl(int[] a, int[] b) {
+    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
+      unsafe.putOrderedInt(a, byte_offset(i*SCALE), -123);
+      unsafe.putOrderedInt(b, byte_offset(i*SCALE), -103);
+    }
+  }
+  static void test_2vi_scl(int[] a, int[] b, int c, int d) {
+    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
+      unsafe.putOrderedInt(a, byte_offset(i*SCALE), c);
+      unsafe.putOrderedInt(b, byte_offset(i*SCALE), d);
+    }
+  }
+  static void test_cp_alndst(int[] a, int[] b) {
+    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
+      unsafe.putOrderedInt(a, byte_offset(i+ALIGN_OFF), b[i]);
+    }
+  }
+  static void test_cp_alnsrc(int[] a, int[] b) {
+    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
+      unsafe.putOrderedInt(a, byte_offset(i), b[i+ALIGN_OFF]);
+    }
+  }
+  static void test_2ci_aln(int[] a, int[] b) {
+    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
+      unsafe.putOrderedInt(a, byte_offset(i+ALIGN_OFF), -123);
+      unsafe.putOrderedInt(b, byte_offset(i), -103);
+    }
+  }
+  static void test_2vi_aln(int[] a, int[] b, int c, int d) {
+    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
+      unsafe.putOrderedInt(a, byte_offset(i), c);
+      unsafe.putOrderedInt(b, byte_offset(i+ALIGN_OFF), d);
+    }
+  }
+  static void test_cp_unalndst(int[] a, int[] b) {
+    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
+      unsafe.putOrderedInt(a, byte_offset(i+UNALIGN_OFF), b[i]);
+    }
+  }
+  static void test_cp_unalnsrc(int[] a, int[] b) {
+    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
+      unsafe.putOrderedInt(a, byte_offset(i), b[i+UNALIGN_OFF]);
+    }
+  }
+  static void test_2ci_unaln(int[] a, int[] b) {
+    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
+      unsafe.putOrderedInt(a, byte_offset(i+UNALIGN_OFF), -123);
+      unsafe.putOrderedInt(b, byte_offset(i), -103);
+    }
+  }
+  static void test_2vi_unaln(int[] a, int[] b, int c, int d) {
+    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
+      unsafe.putOrderedInt(a, byte_offset(i), c);
+      unsafe.putOrderedInt(b, byte_offset(i+UNALIGN_OFF), d);
+    }
+  }
+
+  static int verify(String text, int i, int elem, int val) {
+    if (elem != val) {
+      System.err.println(text + "[" + i + "] = " + elem + " != " + val);
+      return 1;
+    }
+    return 0;
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compiler/8004867/TestIntUnsafeVolatile.java	Thu Feb 28 10:45:18 2013 -0800
@@ -0,0 +1,990 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+/**
+ * @test
+ * @bug 8004867
+ * @summary VM crashing with assert "share/vm/opto/node.hpp:357 - assert(i < _max) failed: oob"
+ *
+ * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:-OptimizeFill TestIntUnsafeVolatile
+ * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:+OptimizeFill TestIntUnsafeVolatile
+ */
+
+import sun.misc.Unsafe;
+import java.lang.reflect.*;
+
+public class TestIntUnsafeVolatile {
+  private static final int ARRLEN = 97;
+  private static final int ITERS  = 11000;
+  private static final int OFFSET = 3;
+  private static final int SCALE = 2;
+  private static final int ALIGN_OFF = 8;
+  private static final int UNALIGN_OFF = 5;
+
+  private static final Unsafe unsafe;
+  private static final int BASE;
+  static {
+    try {
+      Class c = TestIntUnsafeVolatile.class.getClassLoader().loadClass("sun.misc.Unsafe");
+      Field f = c.getDeclaredField("theUnsafe");
+      f.setAccessible(true);
+      unsafe = (Unsafe)f.get(c);
+      BASE = unsafe.arrayBaseOffset(int[].class);
+    } catch (Exception e) {
+      InternalError err = new InternalError();
+      err.initCause(e);
+      throw err;
+    }
+  }
+
+  public static void main(String args[]) {
+    System.out.println("Testing Integer array unsafe volatile operations");
+    int errn = test(false);
+    if (errn > 0) {
+      System.err.println("FAILED: " + errn + " errors");
+      System.exit(97);
+    }
+    System.out.println("PASSED");
+  }
+
+  static int test(boolean test_only) {
+    int[] a1 = new int[ARRLEN];
+    int[] a2 = new int[ARRLEN];
+    // Initialize
+    for (int i=0; i<ARRLEN; i++) {
+      a1[i] = -1;
+      a2[i] = -1;
+    }
+    System.out.println("Warmup");
+    for (int i=0; i<ITERS; i++) {
+      test_ci(a1);
+      test_vi(a2, 123, -1);
+      test_cp(a1, a2);
+      test_2ci(a1, a2);
+      test_2vi(a1, a2, 123, 103);
+      test_ci_neg(a1, 123);
+      test_vi_neg(a2, 123, 103);
+      test_cp_neg(a1, a2);
+      test_2ci_neg(a1, a2);
+      test_2vi_neg(a1, a2, 123, 103);
+      test_ci_oppos(a1, 123);
+      test_vi_oppos(a2, 123, 103);
+      test_cp_oppos(a1, a2);
+      test_2ci_oppos(a1, a2);
+      test_2vi_oppos(a1, a2, 123, 103);
+      test_ci_off(a1, 123);
+      test_vi_off(a2, 123, 103);
+      test_cp_off(a1, a2);
+      test_2ci_off(a1, a2);
+      test_2vi_off(a1, a2, 123, 103);
+      test_ci_inv(a1, OFFSET, 123);
+      test_vi_inv(a2, 123, OFFSET, 103);
+      test_cp_inv(a1, a2, OFFSET);
+      test_2ci_inv(a1, a2, OFFSET);
+      test_2vi_inv(a1, a2, 123, 103, OFFSET);
+      test_ci_scl(a1, 123);
+      test_vi_scl(a2, 123, 103);
+      test_cp_scl(a1, a2);
+      test_2ci_scl(a1, a2);
+      test_2vi_scl(a1, a2, 123, 103);
+      test_cp_alndst(a1, a2);
+      test_cp_alnsrc(a1, a2);
+      test_2ci_aln(a1, a2);
+      test_2vi_aln(a1, a2, 123, 103);
+      test_cp_unalndst(a1, a2);
+      test_cp_unalnsrc(a1, a2);
+      test_2ci_unaln(a1, a2);
+      test_2vi_unaln(a1, a2, 123, 103);
+    }
+    // Initialize
+    for (int i=0; i<ARRLEN; i++) {
+      a1[i] = -1;
+      a2[i] = -1;
+    }
+    // Test and verify results
+    System.out.println("Verification");
+    int errn = 0;
+    {
+      test_ci(a1);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_ci: a1", i, a1[i], -123);
+      }
+      test_vi(a2, 123, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_vi: a2", i, a2[i], 123);
+      }
+      test_cp(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_cp: a1", i, a1[i], 123);
+      }
+      test_2ci(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_2ci: a1", i, a1[i], -123);
+        errn += verify("test_2ci: a2", i, a2[i], -103);
+      }
+      test_2vi(a1, a2, 123, 103);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_2vi: a1", i, a1[i], 123);
+        errn += verify("test_2vi: a2", i, a2[i], 103);
+      }
+      // Reset for negative stride
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+        a2[i] = -1;
+      }
+      test_ci_neg(a1, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_ci_neg: a1", i, a1[i], -123);
+      }
+      test_vi_neg(a2, 123, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_vi_neg: a2", i, a2[i], 123);
+      }
+      test_cp_neg(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_cp_neg: a1", i, a1[i], 123);
+      }
+      test_2ci_neg(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_2ci_neg: a1", i, a1[i], -123);
+        errn += verify("test_2ci_neg: a2", i, a2[i], -103);
+      }
+      test_2vi_neg(a1, a2, 123, 103);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_2vi_neg: a1", i, a1[i], 123);
+        errn += verify("test_2vi_neg: a2", i, a2[i], 103);
+      }
+      // Reset for opposite stride
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+        a2[i] = -1;
+      }
+      test_ci_oppos(a1, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_ci_oppos: a1", i, a1[i], -123);
+      }
+      test_vi_oppos(a2, 123, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_vi_oppos: a2", i, a2[i], 123);
+      }
+      test_cp_oppos(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_cp_oppos: a1", i, a1[i], 123);
+      }
+      test_2ci_oppos(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_2ci_oppos: a1", i, a1[i], -123);
+        errn += verify("test_2ci_oppos: a2", i, a2[i], -103);
+      }
+      test_2vi_oppos(a1, a2, 123, 103);
+      for (int i=0; i<ARRLEN; i++) {
+        errn += verify("test_2vi_oppos: a1", i, a1[i], 123);
+        errn += verify("test_2vi_oppos: a2", i, a2[i], 103);
+      }
+      // Reset for indexing with offset
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+        a2[i] = -1;
+      }
+      test_ci_off(a1, -1);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_ci_off: a1", i, a1[i], -123);
+      }
+      test_vi_off(a2, 123, -1);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_vi_off: a2", i, a2[i], 123);
+      }
+      test_cp_off(a1, a2);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_cp_off: a1", i, a1[i], 123);
+      }
+      test_2ci_off(a1, a2);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_2ci_off: a1", i, a1[i], -123);
+        errn += verify("test_2ci_off: a2", i, a2[i], -103);
+      }
+      test_2vi_off(a1, a2, 123, 103);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_2vi_off: a1", i, a1[i], 123);
+        errn += verify("test_2vi_off: a2", i, a2[i], 103);
+      }
+      for (int i=0; i<OFFSET; i++) {
+        errn += verify("test_2vi_off: a1", i, a1[i], -1);
+        errn += verify("test_2vi_off: a2", i, a2[i], -1);
+      }
+      // Reset for indexing with invariant offset
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+        a2[i] = -1;
+      }
+      test_ci_inv(a1, OFFSET, -1);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_ci_inv: a1", i, a1[i], -123);
+      }
+      test_vi_inv(a2, 123, OFFSET, -1);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_vi_inv: a2", i, a2[i], 123);
+      }
+      test_cp_inv(a1, a2, OFFSET);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_cp_inv: a1", i, a1[i], 123);
+      }
+      test_2ci_inv(a1, a2, OFFSET);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_2ci_inv: a1", i, a1[i], -123);
+        errn += verify("test_2ci_inv: a2", i, a2[i], -103);
+      }
+      test_2vi_inv(a1, a2, 123, 103, OFFSET);
+      for (int i=OFFSET; i<ARRLEN; i++) {
+        errn += verify("test_2vi_inv: a1", i, a1[i], 123);
+        errn += verify("test_2vi_inv: a2", i, a2[i], 103);
+      }
+      for (int i=0; i<OFFSET; i++) {
+        errn += verify("test_2vi_inv: a1", i, a1[i], -1);
+        errn += verify("test_2vi_inv: a2", i, a2[i], -1);
+      }
+      // Reset for indexing with scale
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+        a2[i] = -1;
+      }
+      test_ci_scl(a1, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        int val = (i%SCALE != 0) ? -1 : -123;
+        errn += verify("test_ci_scl: a1", i, a1[i], val);
+      }
+      test_vi_scl(a2, 123, -1);
+      for (int i=0; i<ARRLEN; i++) {
+        int val = (i%SCALE != 0) ? -1 : 123;
+        errn += verify("test_vi_scl: a2", i, a2[i], val);
+      }
+      test_cp_scl(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        int val = (i%SCALE != 0) ? -1 : 123;
+        errn += verify("test_cp_scl: a1", i, a1[i], val);
+      }
+      test_2ci_scl(a1, a2);
+      for (int i=0; i<ARRLEN; i++) {
+        if (i%SCALE != 0) {
+          errn += verify("test_2ci_scl: a1", i, a1[i], -1);
+        } else if (i*SCALE < ARRLEN) {
+          errn += verify("test_2ci_scl: a1", i*SCALE, a1[i*SCALE], -123);
+        }
+        if (i%SCALE != 0) {
+          errn += verify("test_2ci_scl: a2", i, a2[i], -1);
+        } else if (i*SCALE < ARRLEN) {
+          errn += verify("test_2ci_scl: a2", i*SCALE, a2[i*SCALE], -103);
+        }
+      }
+      test_2vi_scl(a1, a2, 123, 103);
+      for (int i=0; i<ARRLEN; i++) {
+        if (i%SCALE != 0) {
+          errn += verify("test_2vi_scl: a1", i, a1[i], -1);
+        } else if (i*SCALE < ARRLEN) {
+          errn += verify("test_2vi_scl: a1", i*SCALE, a1[i*SCALE], 123);
+        }
+        if (i%SCALE != 0) {
+          errn += verify("test_2vi_scl: a2", i, a2[i], -1);
+        } else if (i*SCALE < ARRLEN) {
+          errn += verify("test_2vi_scl: a2", i*SCALE, a2[i*SCALE], 103);
+        }
+      }
+      // Reset for 2 arrays with relative aligned offset
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+        a2[i] = -1;
+      }
+      test_vi(a2, 123, -1);
+      test_cp_alndst(a1, a2);
+      for (int i=0; i<ALIGN_OFF; i++) {
+        errn += verify("test_cp_alndst: a1", i, a1[i], -1);
+      }
+      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_cp_alndst: a1", i, a1[i], 123);
+      }
+      for (int i=0; i<ALIGN_OFF; i++) {
+        a1[i] = 123;
+      }
+      test_vi(a2, -123, 123);
+      test_cp_alnsrc(a1, a2);
+      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+        errn += verify("test_cp_alnsrc: a1", i, a1[i], -123);
+      }
+      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_cp_alnsrc: a1", i, a1[i], 123);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+        a2[i] = -1;
+      }
+      test_2ci_aln(a1, a2);
+      for (int i=0; i<ALIGN_OFF; i++) {
+        errn += verify("test_2ci_aln: a1", i, a1[i], -1);
+      }
+      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2ci_aln: a1", i, a1[i], -123);
+      }
+      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+        errn += verify("test_2ci_aln: a2", i, a2[i], -103);
+      }
+      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2ci_aln: a2", i, a2[i], -1);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+        a2[i] = -1;
+      }
+      test_2vi_aln(a1, a2, 123, 103);
+      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+        errn += verify("test_2vi_aln: a1", i, a1[i], 123);
+      }
+      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2vi_aln: a1", i, a1[i], -1);
+      }
+      for (int i=0; i<ALIGN_OFF; i++) {
+        errn += verify("test_2vi_aln: a2", i, a2[i], -1);
+      }
+      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2vi_aln: a2", i, a2[i], 103);
+      }
+
+      // Reset for 2 arrays with relative unaligned offset
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+        a2[i] = -1;
+      }
+      test_vi(a2, 123, -1);
+      test_cp_unalndst(a1, a2);
+      for (int i=0; i<UNALIGN_OFF; i++) {
+        errn += verify("test_cp_unalndst: a1", i, a1[i], -1);
+      }
+      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_cp_unalndst: a1", i, a1[i], 123);
+      }
+      test_vi(a2, -123, 123);
+      test_cp_unalnsrc(a1, a2);
+      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+        errn += verify("test_cp_unalnsrc: a1", i, a1[i], -123);
+      }
+      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_cp_unalnsrc: a1", i, a1[i], 123);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+        a2[i] = -1;
+      }
+      test_2ci_unaln(a1, a2);
+      for (int i=0; i<UNALIGN_OFF; i++) {
+        errn += verify("test_2ci_unaln: a1", i, a1[i], -1);
+      }
+      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2ci_unaln: a1", i, a1[i], -123);
+      }
+      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+        errn += verify("test_2ci_unaln: a2", i, a2[i], -103);
+      }
+      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2ci_unaln: a2", i, a2[i], -1);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+        a2[i] = -1;
+      }
+      test_2vi_unaln(a1, a2, 123, 103);
+      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+        errn += verify("test_2vi_unaln: a1", i, a1[i], 123);
+      }
+      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2vi_unaln: a1", i, a1[i], -1);
+      }
+      for (int i=0; i<UNALIGN_OFF; i++) {
+        errn += verify("test_2vi_unaln: a2", i, a2[i], -1);
+      }
+      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2vi_unaln: a2", i, a2[i], 103);
+      }
+
+      // Reset for aligned overlap initialization
+      for (int i=0; i<ALIGN_OFF; i++) {
+        a1[i] = i;
+      }
+      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+        a1[i] = -1;
+      }
+      test_cp_alndst(a1, a1);
+      for (int i=0; i<ARRLEN; i++) {
+        int v = i%ALIGN_OFF;
+        errn += verify("test_cp_alndst_overlap: a1", i, a1[i], v);
+      }
+      for (int i=0; i<ALIGN_OFF; i++) {
+        a1[i+ALIGN_OFF] = -1;
+      }
+      test_cp_alnsrc(a1, a1);
+      for (int i=0; i<ALIGN_OFF; i++) {
+        errn += verify("test_cp_alnsrc_overlap: a1", i, a1[i], -1);
+      }
+      for (int i=ALIGN_OFF; i<ARRLEN; i++) {
+        int v = i%ALIGN_OFF;
+        errn += verify("test_cp_alnsrc_overlap: a1", i, a1[i], v);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+      }
+      test_2ci_aln(a1, a1);
+      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+        errn += verify("test_2ci_aln_overlap: a1", i, a1[i], -103);
+      }
+      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2ci_aln_overlap: a1", i, a1[i], -123);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+      }
+      test_2vi_aln(a1, a1, 123, 103);
+      for (int i=0; i<ARRLEN-ALIGN_OFF; i++) {
+        errn += verify("test_2vi_aln_overlap: a1", i, a1[i], 123);
+      }
+      for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2vi_aln_overlap: a1", i, a1[i], 103);
+      }
+
+      // Reset for unaligned overlap initialization
+      for (int i=0; i<UNALIGN_OFF; i++) {
+        a1[i] = i;
+      }
+      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+        a1[i] = -1;
+      }
+      test_cp_unalndst(a1, a1);
+      for (int i=0; i<ARRLEN; i++) {
+        int v = i%UNALIGN_OFF;
+        errn += verify("test_cp_unalndst_overlap: a1", i, a1[i], v);
+      }
+      for (int i=0; i<UNALIGN_OFF; i++) {
+        a1[i+UNALIGN_OFF] = -1;
+      }
+      test_cp_unalnsrc(a1, a1);
+      for (int i=0; i<UNALIGN_OFF; i++) {
+        errn += verify("test_cp_unalnsrc_overlap: a1", i, a1[i], -1);
+      }
+      for (int i=UNALIGN_OFF; i<ARRLEN; i++) {
+        int v = i%UNALIGN_OFF;
+        errn += verify("test_cp_unalnsrc_overlap: a1", i, a1[i], v);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+      }
+      test_2ci_unaln(a1, a1);
+      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+        errn += verify("test_2ci_unaln_overlap: a1", i, a1[i], -103);
+      }
+      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2ci_unaln_overlap: a1", i, a1[i], -123);
+      }
+      for (int i=0; i<ARRLEN; i++) {
+        a1[i] = -1;
+      }
+      test_2vi_unaln(a1, a1, 123, 103);
+      for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) {
+        errn += verify("test_2vi_unaln_overlap: a1", i, a1[i], 123);
+      }
+      for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) {
+        errn += verify("test_2vi_unaln_overlap: a1", i, a1[i], 103);
+      }
+
+    }
+
+    if (errn > 0 || test_only)
+      return errn;
+
+    // Initialize
+    for (int i=0; i<ARRLEN; i++) {
+      a1[i] = -1;
+      a2[i] = -1;
+    }
+    System.out.println("Time");
+    long start, end;
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_ci(a1);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_ci: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_vi(a2, 123, -1);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_vi: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_ci_neg(a1, 123);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_ci_neg: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_vi_neg(a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_vi_neg: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_neg(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_neg: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_neg(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_neg: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_neg(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_neg: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_ci_oppos(a1, 123);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_ci_oppos: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_vi_oppos(a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_vi_oppos: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_oppos(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_oppos: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_oppos(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_oppos: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_oppos(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_oppos: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_ci_off(a1, 123);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_ci_off: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_vi_off(a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_vi_off: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_off(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_off: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_off(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_off: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_off(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_off: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_ci_inv(a1, OFFSET, 123);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_ci_inv: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_vi_inv(a2, 123, OFFSET, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_vi_inv: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_inv(a1, a2, OFFSET);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_inv: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_inv(a1, a2, OFFSET);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_inv: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_inv(a1, a2, 123, 103, OFFSET);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_inv: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_ci_scl(a1, 123);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_ci_scl: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_vi_scl(a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_vi_scl: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_scl(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_scl: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_scl(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_scl: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_scl(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_scl: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_alndst(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_alndst: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_alnsrc(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_alnsrc: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_aln(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_aln: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_aln(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_aln: " + (end - start));
+
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_unalndst(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_unalndst: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_cp_unalnsrc(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_cp_unalnsrc: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2ci_unaln(a1, a2);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2ci_unaln: " + (end - start));
+    start = System.currentTimeMillis();
+    for (int i=0; i<ITERS; i++) {
+      test_2vi_unaln(a1, a2, 123, 103);
+    }
+    end = System.currentTimeMillis();
+    System.out.println("test_2vi_unaln: " + (end - start));
+
+    return errn;
+  }
+
+  private final static long byte_offset(int i) {
+    return ((long)i << 2) + BASE;
+  }
+
+  static void test_ci(int[] a) {
+    for (int i = 0; i < ARRLEN; i+=1) {
+      unsafe.putIntVolatile(a, byte_offset(i), -123);
+    }
+  }
+  static void test_vi(int[] a, int b, int old) {
+    for (int i = 0; i < ARRLEN; i+=1) {
+      unsafe.putIntVolatile(a, byte_offset(i), b);
+    }
+  }
+  static void test_cp(int[] a, int[] b) {
+    for (int i = 0; i < ARRLEN; i+=1) {
+      unsafe.putIntVolatile(a, byte_offset(i), b[i]);
+    }
+  }
+  static void test_2ci(int[] a, int[] b) {
+    for (int i = 0; i < ARRLEN; i+=1) {
+      unsafe.putIntVolatile(a, byte_offset(i), -123);
+      unsafe.putIntVolatile(b, byte_offset(i), -103);
+    }
+  }
+  static void test_2vi(int[] a, int[] b, int c, int d) {
+    for (int i = 0; i < ARRLEN; i+=1) {
+      unsafe.putIntVolatile(a, byte_offset(i), c);
+      unsafe.putIntVolatile(b, byte_offset(i), d);
+    }
+  }
+  static void test_ci_neg(int[] a, int old) {
+    for (int i = ARRLEN-1; i >= 0; i-=1) {
+      unsafe.putIntVolatile(a, byte_offset(i), -123);
+    }
+  }
+  static void test_vi_neg(int[] a, int b, int old) {
+    for (int i = ARRLEN-1; i >= 0; i-=1) {
+      unsafe.putIntVolatile(a, byte_offset(i), b);
+    }
+  }
+  static void test_cp_neg(int[] a, int[] b) {
+    for (int i = ARRLEN-1; i >= 0; i-=1) {
+      unsafe.putIntVolatile(a, byte_offset(i), b[i]);
+    }
+  }
+  static void test_2ci_neg(int[] a, int[] b) {
+    for (int i = ARRLEN-1; i >= 0; i-=1) {
+      unsafe.putIntVolatile(a, byte_offset(i), -123);
+      unsafe.putIntVolatile(b, byte_offset(i), -103);
+    }
+  }
+  static void test_2vi_neg(int[] a, int[] b, int c, int d) {
+    for (int i = ARRLEN-1; i >= 0; i-=1) {
+      unsafe.putIntVolatile(a, byte_offset(i), c);
+      unsafe.putIntVolatile(b, byte_offset(i), d);
+    }
+  }
+  static void test_ci_oppos(int[] a, int old) {
+    int limit = ARRLEN-1;
+    for (int i = 0; i < ARRLEN; i+=1) {
+      unsafe.putIntVolatile(a, byte_offset(limit-i), -123);
+    }
+  }
+  static void test_vi_oppos(int[] a, int b, int old) {
+    int limit = ARRLEN-1;
+    for (int i = limit; i >= 0; i-=1) {
+      unsafe.putIntVolatile(a, byte_offset(limit-i), b);
+    }
+  }
+  static void test_cp_oppos(int[] a, int[] b) {
+    int limit = ARRLEN-1;
+    for (int i = 0; i < ARRLEN; i+=1) {
+      unsafe.putIntVolatile(a, byte_offset(i), b[limit-i]);
+    }
+  }
+  static void test_2ci_oppos(int[] a, int[] b) {
+    int limit = ARRLEN-1;
+    for (int i = 0; i < ARRLEN; i+=1) {
+      unsafe.putIntVolatile(a, byte_offset(limit-i), -123);
+      unsafe.putIntVolatile(b, byte_offset(i), -103);
+    }
+  }
+  static void test_2vi_oppos(int[] a, int[] b, int c, int d) {
+    int limit = ARRLEN-1;
+    for (int i = limit; i >= 0; i-=1) {
+      unsafe.putIntVolatile(a, byte_offset(i), c);
+      unsafe.putIntVolatile(b, byte_offset(limit-i), d);
+    }
+  }
+  static void test_ci_off(int[] a, int old) {
+    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
+      unsafe.putIntVolatile(a, byte_offset(i+OFFSET), -123);
+    }
+  }
+  static void test_vi_off(int[] a, int b, int old) {
+    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
+      unsafe.putIntVolatile(a, byte_offset(i+OFFSET), b);
+    }
+  }
+  static void test_cp_off(int[] a, int[] b) {
+    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
+      unsafe.putIntVolatile(a, byte_offset(i+OFFSET), b[i+OFFSET]);
+    }
+  }
+  static void test_2ci_off(int[] a, int[] b) {
+    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
+      unsafe.putIntVolatile(a, byte_offset(i+OFFSET), -123);
+      unsafe.putIntVolatile(b, byte_offset(i+OFFSET), -103);
+    }
+  }
+  static void test_2vi_off(int[] a, int[] b, int c, int d) {
+    for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
+      unsafe.putIntVolatile(a, byte_offset(i+OFFSET), c);
+      unsafe.putIntVolatile(b, byte_offset(i+OFFSET), d);
+    }
+  }
+  static void test_ci_inv(int[] a, int k, int old) {
+    for (int i = 0; i < ARRLEN-k; i+=1) {
+      unsafe.putIntVolatile(a, byte_offset(i+k), -123);
+    }
+  }
+  static void test_vi_inv(int[] a, int b, int k, int old) {
+    for (int i = 0; i < ARRLEN-k; i+=1) {
+      unsafe.putIntVolatile(a, byte_offset(i+k), b);
+    }
+  }
+  static void test_cp_inv(int[] a, int[] b, int k) {
+    for (int i = 0; i < ARRLEN-k; i+=1) {
+      unsafe.putIntVolatile(a, byte_offset(i+k), b[i+k]);
+    }
+  }
+  static void test_2ci_inv(int[] a, int[] b, int k) {
+    for (int i = 0; i < ARRLEN-k; i+=1) {
+      unsafe.putIntVolatile(a, byte_offset(i+k), -123);
+      unsafe.putIntVolatile(b, byte_offset(i+k), -103);
+    }
+  }
+  static void test_2vi_inv(int[] a, int[] b, int c, int d, int k) {
+    for (int i = 0; i < ARRLEN-k; i+=1) {
+      unsafe.putIntVolatile(a, byte_offset(i+k), c);
+      unsafe.putIntVolatile(b, byte_offset(i+k), d);
+    }
+  }
+  static void test_ci_scl(int[] a, int old) {
+    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
+      unsafe.putIntVolatile(a, byte_offset(i*SCALE), -123);
+    }
+  }
+  static void test_vi_scl(int[] a, int b, int old) {
+    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
+      unsafe.putIntVolatile(a, byte_offset(i*SCALE), b);
+    }
+  }
+  static void test_cp_scl(int[] a, int[] b) {
+    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
+      unsafe.putIntVolatile(a, byte_offset(i*SCALE), b[i*SCALE]);
+    }
+  }
+  static void test_2ci_scl(int[] a, int[] b) {
+    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
+      unsafe.putIntVolatile(a, byte_offset(i*SCALE), -123);
+      unsafe.putIntVolatile(b, byte_offset(i*SCALE), -103);
+    }
+  }
+  static void test_2vi_scl(int[] a, int[] b, int c, int d) {
+    for (int i = 0; i*SCALE < ARRLEN; i+=1) {
+      unsafe.putIntVolatile(a, byte_offset(i*SCALE), c);
+      unsafe.putIntVolatile(b, byte_offset(i*SCALE), d);
+    }
+  }
+  static void test_cp_alndst(int[] a, int[] b) {
+    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
+      unsafe.putIntVolatile(a, byte_offset(i+ALIGN_OFF), b[i]);
+    }
+  }
+  static void test_cp_alnsrc(int[] a, int[] b) {
+    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
+      unsafe.putIntVolatile(a, byte_offset(i), b[i+ALIGN_OFF]);
+    }
+  }
+  static void test_2ci_aln(int[] a, int[] b) {
+    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
+      unsafe.putIntVolatile(a, byte_offset(i+ALIGN_OFF), -123);
+      unsafe.putIntVolatile(b, byte_offset(i), -103);
+    }
+  }
+  static void test_2vi_aln(int[] a, int[] b, int c, int d) {
+    for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
+      unsafe.putIntVolatile(a, byte_offset(i), c);
+      unsafe.putIntVolatile(b, byte_offset(i+ALIGN_OFF), d);
+    }
+  }
+  static void test_cp_unalndst(int[] a, int[] b) {
+    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
+      unsafe.putIntVolatile(a, byte_offset(i+UNALIGN_OFF), b[i]);
+    }
+  }
+  static void test_cp_unalnsrc(int[] a, int[] b) {
+    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
+      unsafe.putIntVolatile(a, byte_offset(i), b[i+UNALIGN_OFF]);
+    }
+  }
+  static void test_2ci_unaln(int[] a, int[] b) {
+    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
+      unsafe.putIntVolatile(a, byte_offset(i+UNALIGN_OFF), -123);
+      unsafe.putIntVolatile(b, byte_offset(i), -103);
+    }
+  }
+  static void test_2vi_unaln(int[] a, int[] b, int c, int d) {
+    for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
+      unsafe.putIntVolatile(a, byte_offset(i), c);
+      unsafe.putIntVolatile(b, byte_offset(i+UNALIGN_OFF), d);
+    }
+  }
+
+  static int verify(String text, int i, int elem, int val) {
+    if (elem != val) {
+      System.err.println(text + "[" + i + "] = " + elem + " != " + val);
+      return 1;
+    }
+    return 0;
+  }
+}