From baf102dbb23f13324ee74904fd8c35c45ab72774 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Sun, 31 Mar 2019 02:14:53 +0100 Subject: [PATCH] compiler: Fix comparison of nested lists --- artiq/compiler/transforms/artiq_ir_generator.py | 5 +++-- artiq/test/lit/integration/list.py | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/artiq/compiler/transforms/artiq_ir_generator.py b/artiq/compiler/transforms/artiq_ir_generator.py index 25dd1d14a..332cb2a4a 100644 --- a/artiq/compiler/transforms/artiq_ir_generator.py +++ b/artiq/compiler/transforms/artiq_ir_generator.py @@ -1453,6 +1453,7 @@ class ARTIQIRGenerator(algorithm.Visitor): lhs_elt = self.append(ir.GetElem(lhs, index_phi)) rhs_elt = self.append(ir.GetElem(rhs, index_phi)) body_result = self.polymorphic_compare_pair(op, lhs_elt, rhs_elt) + body_end = self.current_block loop_body2 = self.add_block("compare.body2") self.current_block = loop_body2 @@ -1468,8 +1469,8 @@ class ARTIQIRGenerator(algorithm.Visitor): phi.add_incoming(compare_length, head) loop_head.append(ir.BranchIf(loop_cond, loop_body, tail)) phi.add_incoming(ir.Constant(True, builtins.TBool()), loop_head) - loop_body.append(ir.BranchIf(body_result, loop_body2, tail)) - phi.add_incoming(body_result, loop_body) + body_end.append(ir.BranchIf(body_result, loop_body2, tail)) + phi.add_incoming(body_result, body_end) if isinstance(op, ast.NotEq): result = self.append(ir.Select(phi, diff --git a/artiq/test/lit/integration/list.py b/artiq/test/lit/integration/list.py index 06f08e426..68ac2809e 100644 --- a/artiq/test/lit/integration/list.py +++ b/artiq/test/lit/integration/list.py @@ -7,3 +7,10 @@ assert (x, y) == (1, 2) lst = [1, 2, 3] assert [x*x for x in lst] == [1, 4, 9] + +assert [0] == [0] +assert [0] != [1] +assert [[0]] == [[0]] +assert [[0]] != [[1]] +assert [[[0]]] == [[[0]]] +assert [[[0]]] != [[[1]]]