Kait Lam supervised by Mark Utting, Ian Hayes, and Brae Webb
char[] a =
char[] b =
for (int i = 0; i < a.length; i++) {
b[i] = a[i];
}
char x[4]; in Java, char[] x.
for (int i = 0; i < a.length; i++) {
assert 0 <= i < b.length;
assert 0 <= i < a.length;
b[i] = a[i];
}
char x[4]; in Java, char[] x.
| GCC | LLVM | |
|---|---|---|
| Front end | 0 | 10 |
| Middle end | 49 | 75 |
| Back end | 17 | 74 |
| Unclassified | 13 | 43 |
| Total | 79 | 202 |
public static void f(int[] a, int[] b) {
for (int i = 0; i < a.length; i++) {
b[i] = a[i];
}
}
LoadIndexedNode:
⟦ kind g nid = (LoadIndexedNode index guard array nid');
(* convert and evaluate the index *)
g ⊢ index ≃ indexE;
[m, p] ⊢ indexE ↦ indexVal;
(* convert and evaluate the array object *)
g ⊢ array ≃ arrayE;
[m, p] ⊢ arrayE ↦ ObjRef ref;
(* load from this index *)
h_load_field '''' ref h = arrayVal;
loaded = intval_load_index arrayVal indexVal;
(* record the result under this node id *)
m' = m(nid := loaded) ⟧
⟹ g, p ⊢ (nid, m, h) → (nid', m', h)
public class ArrayBoundsCheckEliminationTestCases {
public static int constant_p(int[] a) {
return a[5];
}
public static int constant_f(int[] a) {
if (!(0 <= 5 && 5 < a.length))
return -1;
return a[5];
}
public static int param_p(int[] a, int x) {
return a[x];
}
public static int param_f(int[] a, int x) {
if (!(0 <= x && x < a.length))
return -1;
return a[x];
}
public static int param_f_trans(int[] a, int x, int lower, int upper) {
if (!(0 <= lower))
return -1;
if (!(upper < a.length))
return -1;
if (!(lower <= x))
return -1;
if (!(x <= upper))
return -1;
return a[x];
}
public static int loop1_p(int[] a, int max) {
int s = 0;
for (int i = 0; i < max; i++) {
s += a[i];
}
return s;
}
public static int loop1_f(int[] a) {
int s = 0;
for (int i = 0; i < a.length; i++) {
s += a[i];
}
return s;
}
public static int loop1plus5_p(int[] a, int max) {
int s = 0;
for (int i = 0; i < max - 5; i++) {
s += a[i + 5];
}
return s;
}
public static int loop1plus5_f(int[] a) {
int s = 0;
for (int i = 0; i < a.length - 5; i++) {
s += a[i + 5];
}
return s;
}
public static int loop1plusc_p(int[] a, int max, int c) {
int s = 0;
for (int i = 0; i < max - c; i++) {
s += a[i + c];
}
return s;
}
public static int loop1plusc_f(int[] a, int c) {
int s = 0;
for (int i = 0; i < a.length - c; i++) {
s += a[i + c];
}
return s;
}
public static int loop1double_p(int[] a, int max) {
int s = 0;
for (int i = 0; i < max / 2; i++) {
s += a[2*i] + a[2*i+1];
}
return s;
}
public static int loop1double_f(int[] a, int c) {
int s = 0;
for (int i = 0; i < a.length / 2; i++) {
s += a[2*i] + a[2*i+1];
}
return s;
}
public static int loop2i_p(int[] a, int imax, int jmax) {
int s = 0;
for (int i = 0; i < imax; i++) {
for (int j = 0; j < jmax; j++) {
s += a[i];
s += a[j];
}
}
return s;
}
public static int loop2i_f(int[] a) {
int s = 0;
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < a.length; j++) {
s += a[i];
s += a[j];
}
}
return s;
}
public static int loop2triangular_p(int[] a, int imax, int jmax) {
int s = 0;
for (int i = 0; i < imax; i++) {
for (int j = 0; j < i; j++) {
s += a[i];
s += a[j];
}
}
return s;
}
public static int loop2trianglular_f(int[] a) {
int s = 0;
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < i; j++) {
s += a[i];
s += a[j];
}
}
return s;
}
public static int loop2lowertri_p(int[] a, int imax, int jmax) {
int s = 0;
for (int i = 0; i < imax; i++) {
for (int j = 0; j < i; j++) {
s += a[i];
s += a[j];
}
}
return s;
}
public static int loop2lowertri_f(int[] a) {
int s = 0;
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < i; j++) {
s += a[i];
s += a[j];
}
}
return s;
}
public static int loop2uppertri_p(int[] a, int imax, int jmax) {
int s = 0;
for (int i = 0; i < imax; i++) {
for (int j = i; j < jmax; j++) {
s += a[i];
s += a[j];
}
}
return s;
}
public static int loop2uppertri_f(int[] a) {
int s = 0;
for (int i = 0; i < a.length; i++) {
for (int j = i; j < a.length; j++) {
s += a[i];
s += a[j];
}
}
return s;
}
public static int loop2sum_p(int[] a, int imax, int jmax) {
int s = 0;
for (int i = 0; i < imax; i++) {
for (int j = 0; j < jmax - i; j++) {
s += a[i + j];
}
}
return s;
}
public static int loop2sum_f(int[] a) {
int s = 0;
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < a.length - i; j++) {
s += a[i + j];
}
}
return s;
}
public static int loop2sumplus5_p(int[] a, int imax, int jmax) {
int s = 0;
for (int i = 0; i < imax; i++) {
for (int j = 0; j < jmax - i - 5; j++) {
s += a[i + j + 5];
}
}
return s;
}
public static int loop2sumplus5_f(int[] a) {
int s = 0;
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < a.length - i - 5; j++) {
s += a[i + j + 5];
}
}
return s;
}
public static int loop2addmul_p(int[] a, int imax, int jmax) {
int s = 0;
for (int i = 0; i < imax / 4; i++) {
for (int j = 0; j < 4; j++) {
s += a[j + 4 * i];
}
}
return s;
}
public static int loop2addmul_f(int[] a) {
int s = 0;
for (int i = 0; i < a.length / 4; i++) {
for (int j = 0; j < 4; j++) {
s += a[j + 4 * i];
}
}
return s;
}
}
![]() |
![]() |
![]() |
![]() |