Skip to content

Commit

Permalink
Fix normalization of array reference comparison for normalized arrays (
Browse files Browse the repository at this point in the history
  • Loading branch information
titzer authored Jan 7, 2025
1 parent c887bea commit c445353
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 3 deletions.
4 changes: 2 additions & 2 deletions aeneas/src/ir/SsaNormalizer.v3
Original file line number Diff line number Diff line change
Expand Up @@ -681,9 +681,9 @@ class SsaRaNormalizer extends SsaRebuilder {
return expr;
}
def normSimpleEqualOp(i_old: SsaApplyOp, op: Operator) {
var tn = normTypeArg(op, 0);
var refs = genRefs(i_old.inputs);
return map1(i_old, curBlock.opEqualOf(op, refs[0], refs[1]));
var tn = normTypeArg(op, 0), size = if(tn == null, 1, tn.size);
return map1(i_old, curBlock.opEqualOf(op, refs[0], refs[size]));
}
def normVariantEqual(i_old: SsaApplyOp, t: Type, x: SsaInstr, y: SsaInstr) -> SsaInstr {
var rc = norm.ra.getClass(t);
Expand Down
2 changes: 1 addition & 1 deletion aeneas/src/main/Version.v3
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

// Updated by VCS scripts. DO NOT EDIT.
component Version {
def version: string = "III-7.1780";
def version: string = "III-7.1781";
var buildData: string;
}
6 changes: 6 additions & 0 deletions test/core/array_id00.v3
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//@execute 0=true; 1=false
var x = Array<int>.new(0);
var ax = [x, null];
def main(i: int) -> bool {
return ax[i] == x;
}
6 changes: 6 additions & 0 deletions test/core/array_id01.v3
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//@execute 0=true; 1=false
var x = Array<(bool, int)>.new(0);
var ax = [x, null];
def main(i: int) -> bool {
return ax[i] == x;
}
6 changes: 6 additions & 0 deletions test/core/array_id02.v3
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//@execute 0=true; 1=false
def main(i: int) -> bool {
var x = Array<(bool, int)>.new(0);
var ax = [x, null];
return ax[i] == x;
}
7 changes: 7 additions & 0 deletions test/core/array_id03.v3
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//@execute 0=true; 1=false; 2=false
var x = Array<int>.new(0);
var y = Array<int>.new(0);
def main(i: int) -> bool {
var other = if(i == 0, x, if(i == 1, y));
return x == other;
}
7 changes: 7 additions & 0 deletions test/core/array_id04.v3
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//@execute 0=true; 1=false; 2=false
var x = Array<(int, void, string)>.new(0);
var y = Array<(int, void, string)>.new(0);
def main(i: int) -> bool {
var other = if(i == 0, x, if(i == 1, y));
return x == other;
}
8 changes: 8 additions & 0 deletions test/core/array_id05.v3
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//@execute 0=true; 1=false; 2=false
var x = Array<(int, void, string)>.new(0);
var y = Array<(int, void, string)>.new(0);
def eq = Array<(int, void, string)>.==;
def main(i: int) -> bool {
var other = if(i == 0, x, if(i == 1, y));
return eq(x, other);
}
8 changes: 8 additions & 0 deletions test/core/array_id06.v3
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//@execute 0=true; 1=false; 2=false
var x = Array<Array<(int, void, string)>>.new(0);
var y = Array<Array<(int, void, string)>>.new(0);
def eq = Array<Array<(int, void, string)>>.==;
def main(i: int) -> bool {
var other = if(i == 0, x, if(i == 1, y));
return eq(x, other);
}
10 changes: 10 additions & 0 deletions test/variants/unboxed_array_id00.v3
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//@execute 0=true; 1=false; 2=false
type T(x: int, y: void, z: string) #unboxed;

var x = Array<T>.new(0);
var y = Array<T>.new(0);
def eq = Array<T>.==;
def main(i: int) -> bool {
var other = if(i == 0, x, if(i == 1, y));
return eq(x, other);
}
10 changes: 10 additions & 0 deletions test/variants/unboxed_array_id01.v3
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//@execute 0=true; 1=false; 2=false
type T(x: Array<(int, int)>) #unboxed;

var x = Array<T>.new(0);
var y = Array<T>.new(0);
def eq = Array<T>.==;
def main(i: int) -> bool {
var other = if(i == 0, x, if(i == 1, y));
return eq(x, other);
}

0 comments on commit c445353

Please sign in to comment.