Fix bug in vectorization of charAt, with regression test

Rationale:
String array get instruction cannot be vectorized
in a straightforward way, since compression has
to be dealt with. So rejected for now.

Test: test-art-target, test-art-host
Bug: 37151445
Change-Id: I16112cb8b1be30babd8ec07af5976db0369f8c28
(cherry picked from commit 3101e58114b21876f77940d716385c54f697761b)
diff --git a/compiler/optimizing/loop_optimization.cc b/compiler/optimizing/loop_optimization.cc
index bf18cc9..05395ed 100644
--- a/compiler/optimizing/loop_optimization.cc
+++ b/compiler/optimizing/loop_optimization.cc
@@ -623,6 +623,12 @@
     }
     return true;
   } else if (instruction->IsArrayGet()) {
+    // Strings are different, with a different offset to the actual data
+    // and some compressed to save memory. For now, all cases are rejected
+    // to avoid the complexity.
+    if (instruction->AsArrayGet()->IsStringCharAt()) {
+      return false;
+    }
     // Accept a right-hand-side array base[index] for
     // (1) exact matching vector type,
     // (2) loop-invariant base,
diff --git a/test/623-checker-loop-regressions/src/Main.java b/test/623-checker-loop-regressions/src/Main.java
index 182c07d..f0b3278 100644
--- a/test/623-checker-loop-regressions/src/Main.java
+++ b/test/623-checker-loop-regressions/src/Main.java
@@ -280,6 +280,14 @@
     }
   }
 
+  // If vectorized, string encoding should be dealt with.
+  private static void string2Bytes(char[] a, String b) {
+    int min = Math.min(a.length, b.length());
+    for (int i = 0; i < min; i++) {
+      a[i] = b.charAt(i);
+    }
+  }
+
   public static void main(String[] args) {
     expectEquals(10, earlyExitFirst(-1));
     for (int i = 0; i <= 10; i++) {
@@ -354,6 +362,13 @@
       expectEquals(2, yy[i]);
     }
 
+    char[] aa = new char[23];
+    String bb = "hello world how are you";
+    string2Bytes(aa, bb);
+    for (int i = 0; i < aa.length; i++) {
+      expectEquals(aa[i], bb.charAt(i));
+    }
+
     System.out.println("passed");
   }