Skip to content

Commit 048e7c4

Browse files
authored
Remove TwinPhasedX and replace with individual PhasedX in rebases (#1485)
1 parent cabe853 commit 048e7c4

14 files changed

Lines changed: 282 additions & 367 deletions

File tree

qis-compiler/python/tests/generate_hugrs.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
from pathlib import Path
1010

1111
from guppylang import guppy
12-
from guppylang.std.builtins import array, exit, panic, result
1312
from guppylang.std.angles import pi
13+
from guppylang.std.builtins import array, exit, panic, result
1414
from guppylang.std.qsystem.random import RNG
1515
from guppylang.std.qsystem.utils import get_current_shot
1616
from guppylang.std.quantum import (
17+
crz,
1718
cx,
1819
discard,
1920
discard_array,
@@ -25,7 +26,6 @@
2526
tdg,
2627
x,
2728
z,
28-
crz,
2929
)
3030

3131
resources_dir = Path(__file__).parent / "resources"
@@ -220,6 +220,7 @@ def main() -> None:
220220

221221
return main.compile().to_bytes()
222222

223+
223224
def qft_32() -> bytes:
224225
@guppy
225226
def main() -> None:

qis-compiler/python/tests/snapshots/test_qsystem_platforms/test_llvm_multiplatform/sol-aarch64-apple-darwin-qft_32/qft_32_aarch64-apple-darwin_sol

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ cond_20_case_1: ; preds = %alloca_block, %cond
3131
%2 = add nuw nsw i64 %"15_0.sroa.0.0978", 1
3232
%qalloc.i = tail call i64 @___qalloc()
3333
%not_max.not.not.i = icmp eq i64 %qalloc.i, -1
34-
br i1 %not_max.not.not.i, label %cond_405_case_0.i, label %__barray_check_bounds.exit
34+
br i1 %not_max.not.not.i, label %cond_386_case_0.i, label %__barray_check_bounds.exit
3535

36-
cond_405_case_0.i: ; preds = %cond_20_case_1
36+
cond_386_case_0.i: ; preds = %cond_20_case_1
3737
tail call void @panic(i32 1001, ptr nonnull @"e_No more qu.3B2EEBF0.0")
3838
unreachable
3939

@@ -105,55 +105,55 @@ mask_block_err.i: ; preds = %"__hugr__.$measure_
105105
tail call void @panic(i32 1002, ptr nonnull @"e_Some array.A77EF32E.0")
106106
unreachable
107107

108-
23: ; preds = %__barray_check_none_borrowed.exit, %"__hugr__.$__copy_scan$$n(32)$t([Bool]+[Future(Bool)])$n(1).328.exit"
109-
%storemerge835986 = phi i64 [ 0, %__barray_check_none_borrowed.exit ], [ %31, %"__hugr__.$__copy_scan$$n(32)$t([Bool]+[Future(Bool)])$n(1).328.exit" ]
108+
23: ; preds = %__barray_check_none_borrowed.exit, %"__hugr__.$__copy_scan$$n(32)$t([Bool]+[Future(Bool)])$n(1).300.exit"
109+
%storemerge835986 = phi i64 [ 0, %__barray_check_none_borrowed.exit ], [ %31, %"__hugr__.$__copy_scan$$n(32)$t([Bool]+[Future(Bool)])$n(1).300.exit" ]
110110
%24 = getelementptr inbounds nuw { i1, i64, i1 }, ptr %75, i64 %storemerge835986
111111
%25 = load { i1, i64, i1 }, ptr %24, align 4
112112
%.fca.0.extract118.i = extractvalue { i1, i64, i1 } %25, 0
113-
br i1 %.fca.0.extract118.i, label %cond_299_case_1.i, label %cond_299_case_0.i
113+
br i1 %.fca.0.extract118.i, label %cond_296_case_1.i, label %cond_296_case_0.i
114114

115-
cond_299_case_0.i: ; preds = %23
115+
cond_296_case_0.i: ; preds = %23
116116
%.fca.2.extract120.i = extractvalue { i1, i64, i1 } %25, 2
117-
br label %cond_exit_299.i
117+
br label %cond_exit_296.i
118118

119-
cond_299_case_1.i: ; preds = %23
119+
cond_296_case_1.i: ; preds = %23
120120
%.fca.1.extract119.i = extractvalue { i1, i64, i1 } %25, 1
121121
tail call void @___inc_future_refcount(i64 %.fca.1.extract119.i)
122-
br label %cond_exit_299.i
122+
br label %cond_exit_296.i
123123

124-
cond_exit_299.i: ; preds = %cond_299_case_0.i, %cond_299_case_1.i
125-
%"03.sroa.3.0.i" = phi i64 [ %.fca.1.extract119.i, %cond_299_case_1.i ], [ undef, %cond_299_case_0.i ]
126-
%"03.sroa.6.0.i" = phi i1 [ undef, %cond_299_case_1.i ], [ %.fca.2.extract120.i, %cond_299_case_0.i ]
124+
cond_exit_296.i: ; preds = %cond_296_case_0.i, %cond_296_case_1.i
125+
%"03.sroa.3.0.i" = phi i64 [ %.fca.1.extract119.i, %cond_296_case_1.i ], [ undef, %cond_296_case_0.i ]
126+
%"03.sroa.6.0.i" = phi i1 [ undef, %cond_296_case_1.i ], [ %.fca.2.extract120.i, %cond_296_case_0.i ]
127127
%26 = load i64, ptr %120, align 4
128128
%27 = lshr i64 %26, %storemerge835986
129129
%28 = trunc i64 %27 to i1
130-
br i1 %28, label %panic.i.i, label %cond_296_case_1.i
130+
br i1 %28, label %panic.i.i, label %cond_329_case_1.i
131131

132-
panic.i.i: ; preds = %cond_exit_299.i
132+
panic.i.i: ; preds = %cond_exit_296.i
133133
tail call void @panic(i32 1002, ptr nonnull @"e_Array elem.E746B1A3.0")
134134
unreachable
135135

136-
cond_296_case_1.i: ; preds = %cond_exit_299.i
136+
cond_329_case_1.i: ; preds = %cond_exit_296.i
137137
%"16.fca.1.insert.i" = insertvalue { i1, i64, i1 } %25, i64 %"03.sroa.3.0.i", 1
138138
%"16.fca.2.insert.i" = insertvalue { i1, i64, i1 } %"16.fca.1.insert.i", i1 %"03.sroa.6.0.i", 2
139139
%29 = insertvalue { i1, { i1, i64, i1 } } { i1 true, { i1, i64, i1 } poison }, { i1, i64, i1 } %"16.fca.2.insert.i", 1
140140
%30 = getelementptr inbounds nuw { i1, { i1, i64, i1 } }, ptr %119, i64 %storemerge835986
141141
%.fca.2.0.extract.i = load i1, ptr %30, align 1
142142
store { i1, { i1, i64, i1 } } %29, ptr %30, align 4
143-
br i1 %.fca.2.0.extract.i, label %cond_295_case_1.i, label %"__hugr__.$__copy_scan$$n(32)$t([Bool]+[Future(Bool)])$n(1).328.exit"
143+
br i1 %.fca.2.0.extract.i, label %cond_293_case_1.i, label %"__hugr__.$__copy_scan$$n(32)$t([Bool]+[Future(Bool)])$n(1).300.exit"
144144

145-
cond_295_case_1.i: ; preds = %cond_296_case_1.i
145+
cond_293_case_1.i: ; preds = %cond_329_case_1.i
146146
tail call void @panic(i32 1001, ptr nonnull @"e_Expected v.2F17E0A9.0")
147147
unreachable
148148

149-
"__hugr__.$__copy_scan$$n(32)$t([Bool]+[Future(Bool)])$n(1).328.exit": ; preds = %cond_296_case_1.i
149+
"__hugr__.$__copy_scan$$n(32)$t([Bool]+[Future(Bool)])$n(1).300.exit": ; preds = %cond_329_case_1.i
150150
%31 = add nuw nsw i64 %storemerge835986, 1
151151
%32 = getelementptr inbounds nuw { i1, i64, i1 }, ptr %21, i64 %storemerge835986
152152
store { i1, i64, i1 } %"16.fca.2.insert.i", ptr %32, align 4
153153
%exitcond992.not = icmp eq i64 %31, 32
154154
br i1 %exitcond992.not, label %mask_block_ok.i902, label %23
155155

156-
mask_block_ok.i902: ; preds = %"__hugr__.$__copy_scan$$n(32)$t([Bool]+[Future(Bool)])$n(1).328.exit"
156+
mask_block_ok.i902: ; preds = %"__hugr__.$__copy_scan$$n(32)$t([Bool]+[Future(Bool)])$n(1).300.exit"
157157
tail call void @heap_free(ptr nonnull %75)
158158
tail call void @heap_free(ptr nonnull %76)
159159
%33 = load i64, ptr %120, align 4
@@ -176,7 +176,7 @@ mask_block_err.i905: ; preds = %mask_block_ok.i902
176176
%storemerge840987 = phi i64 [ 0, %__barray_check_none_borrowed.exit907 ], [ %44, %38 ]
177177
%39 = getelementptr { i1, { i1, i64, i1 } }, ptr %119, i64 %storemerge840987
178178
%40 = load { i1, { i1, i64, i1 } }, ptr %39, align 4
179-
%41 = tail call { { i1, i64, i1 } } @"__hugr__.$__unwrap$$t([Bool]+[Future(Bool)]).577"({ i1, { i1, i64, i1 } } %40)
179+
%41 = tail call { { i1, i64, i1 } } @"__hugr__.$__unwrap$$t([Bool]+[Future(Bool)]).580"({ i1, { i1, i64, i1 } } %40)
180180
%42 = getelementptr inbounds nuw { i1, i64, i1 }, ptr %36, i64 %storemerge840987
181181
%43 = extractvalue { { i1, i64, i1 } } %41, 0
182182
store { i1, i64, i1 } %43, ptr %42, align 4
@@ -189,39 +189,39 @@ mask_block_err.i905: ; preds = %mask_block_ok.i902
189189
tail call void @heap_free(ptr nonnull %120)
190190
br label %__barray_check_bounds.exit914
191191

192-
cond_659_case_0: ; preds = %cond_exit_659
192+
cond_662_case_0: ; preds = %cond_exit_662
193193
%46 = load i64, ptr %37, align 4
194194
%47 = or i64 %46, -4294967296
195195
store i64 %47, ptr %37, align 4
196196
%48 = icmp eq i64 %47, -1
197197
br i1 %48, label %loop_out141, label %mask_block_err.i911
198198

199-
mask_block_err.i911: ; preds = %cond_659_case_0
199+
mask_block_err.i911: ; preds = %cond_662_case_0
200200
tail call void @panic(i32 1002, ptr nonnull @"e_Array cont.EFA5AC45.0")
201201
unreachable
202202

203-
__barray_check_bounds.exit914: ; preds = %45, %cond_exit_659
204-
%"656_0.0998" = phi i64 [ 0, %45 ], [ %49, %cond_exit_659 ]
205-
%49 = add nuw nsw i64 %"656_0.0998", 1
203+
__barray_check_bounds.exit914: ; preds = %45, %cond_exit_662
204+
%"659_0.0998" = phi i64 [ 0, %45 ], [ %49, %cond_exit_662 ]
205+
%49 = add nuw nsw i64 %"659_0.0998", 1
206206
%50 = load i64, ptr %37, align 4
207-
%51 = lshr i64 %50, %"656_0.0998"
207+
%51 = lshr i64 %50, %"659_0.0998"
208208
%52 = trunc i64 %51 to i1
209-
br i1 %52, label %cond_exit_659, label %__barray_mask_borrow.exit918
209+
br i1 %52, label %cond_exit_662, label %__barray_mask_borrow.exit918
210210

211211
__barray_mask_borrow.exit918: ; preds = %__barray_check_bounds.exit914
212-
%53 = shl nuw nsw i64 1, %"656_0.0998"
212+
%53 = shl nuw nsw i64 1, %"659_0.0998"
213213
%54 = xor i64 %50, %53
214214
store i64 %54, ptr %37, align 4
215-
%55 = getelementptr inbounds nuw { i1, i64, i1 }, ptr %36, i64 %"656_0.0998"
215+
%55 = getelementptr inbounds nuw { i1, i64, i1 }, ptr %36, i64 %"659_0.0998"
216216
%56 = load { i1, i64, i1 }, ptr %55, align 4
217217
%.fca.0.extract604 = extractvalue { i1, i64, i1 } %56, 0
218-
br i1 %.fca.0.extract604, label %cond_682_case_1, label %cond_exit_659
218+
br i1 %.fca.0.extract604, label %cond_685_case_1, label %cond_exit_662
219219

220-
cond_exit_659: ; preds = %cond_682_case_1, %__barray_mask_borrow.exit918, %__barray_check_bounds.exit914
221-
%57 = icmp samesign ugt i64 %"656_0.0998", 30
222-
br i1 %57, label %cond_659_case_0, label %__barray_check_bounds.exit914
220+
cond_exit_662: ; preds = %cond_685_case_1, %__barray_mask_borrow.exit918, %__barray_check_bounds.exit914
221+
%57 = icmp samesign ugt i64 %"659_0.0998", 30
222+
br i1 %57, label %cond_662_case_0, label %__barray_check_bounds.exit914
223223

224-
loop_out141: ; preds = %cond_659_case_0
224+
loop_out141: ; preds = %cond_662_case_0
225225
tail call void @heap_free(ptr %36)
226226
tail call void @heap_free(ptr nonnull %37)
227227
%58 = load i64, ptr %22, align 4
@@ -240,10 +240,10 @@ mask_block_err.i922: ; preds = %loop_out141
240240
tail call void @panic(i32 1002, ptr nonnull @"e_Some array.A77EF32E.0")
241241
unreachable
242242

243-
cond_682_case_1: ; preds = %__barray_mask_borrow.exit918
243+
cond_685_case_1: ; preds = %__barray_mask_borrow.exit918
244244
%.fca.1.extract605 = extractvalue { i1, i64, i1 } %56, 1
245245
tail call void @___dec_future_refcount(i64 %.fca.1.extract605)
246-
br label %cond_exit_659
246+
br label %cond_exit_662
247247

248248
63: ; preds = %__barray_check_none_borrowed.exit924, %63
249249
%storemerge841988 = phi i64 [ 0, %__barray_check_none_borrowed.exit924 ], [ %69, %63 ]
@@ -454,9 +454,11 @@ __barray_check_bounds.exit943: ; preds = %__barray_check_boun
454454
%141 = fmul double %"131_6.0979", 0x400921FB54442D18
455455
%142 = fmul double %141, 5.000000e-01
456456
%143 = fneg double %142
457-
tail call void @___rpg(i64 %132, i64 %140, double 0x3FF921FB54442D18, double 0xBFF921FB54442D18)
457+
tail call void @___rp(i64 %132, double 0x3FF921FB54442D18, double 0xBFF921FB54442D18)
458+
tail call void @___rp(i64 %140, double 0x3FF921FB54442D18, double 0xBFF921FB54442D18)
458459
tail call void @___rpp(i64 %132, i64 %140, double %143, double 0xC00921FB54442D18)
459-
tail call void @___rpg(i64 %132, i64 %140, double 0x3FF921FB54442D18, double 0x3FF921FB54442D18)
460+
tail call void @___rp(i64 %132, double 0x3FF921FB54442D18, double 0x3FF921FB54442D18)
461+
tail call void @___rp(i64 %140, double 0x3FF921FB54442D18, double 0x3FF921FB54442D18)
460462
tail call void @___rz(i64 %140, double %142)
461463
%144 = load i64, ptr %1, align 4
462464
%145 = lshr i64 %144, %"45_0.0981"
@@ -503,35 +505,35 @@ declare void @___dec_future_refcount(i64) local_unnamed_addr
503505
define internal i1 @__hugr__.array.__read_bool.3.330({ i1, i64, i1 } %0) unnamed_addr {
504506
alloca_block:
505507
%.fca.0.extract = extractvalue { i1, i64, i1 } %0, 0
506-
br i1 %.fca.0.extract, label %cond_382_case_1, label %cond_382_case_0
508+
br i1 %.fca.0.extract, label %cond_373_case_1, label %cond_373_case_0
507509

508-
cond_382_case_0: ; preds = %alloca_block
510+
cond_373_case_0: ; preds = %alloca_block
509511
%.fca.2.extract = extractvalue { i1, i64, i1 } %0, 2
510-
br label %cond_exit_382
512+
br label %cond_exit_373
511513

512-
cond_382_case_1: ; preds = %alloca_block
514+
cond_373_case_1: ; preds = %alloca_block
513515
%.fca.1.extract = extractvalue { i1, i64, i1 } %0, 1
514516
%read_bool = tail call i1 @___read_future_bool(i64 %.fca.1.extract)
515517
tail call void @___dec_future_refcount(i64 %.fca.1.extract)
516-
br label %cond_exit_382
518+
br label %cond_exit_373
517519

518-
cond_exit_382: ; preds = %cond_382_case_1, %cond_382_case_0
519-
%"03.0" = phi i1 [ %read_bool, %cond_382_case_1 ], [ %.fca.2.extract, %cond_382_case_0 ]
520+
cond_exit_373: ; preds = %cond_373_case_1, %cond_373_case_0
521+
%"03.0" = phi i1 [ %read_bool, %cond_373_case_1 ], [ %.fca.2.extract, %cond_373_case_0 ]
520522
ret i1 %"03.0"
521523
}
522524

523525
declare void @heap_free(ptr) local_unnamed_addr
524526

525-
define internal { i1, i64, i1 } @"__hugr__.$__unwrap$$t([Bool]+[Future(Bool)]).577"({ i1, { i1, i64, i1 } } %0) unnamed_addr {
527+
define internal { i1, i64, i1 } @"__hugr__.$__unwrap$$t([Bool]+[Future(Bool)]).580"({ i1, { i1, i64, i1 } } %0) unnamed_addr {
526528
alloca_block:
527529
%.fca.0.extract11 = extractvalue { i1, { i1, i64, i1 } } %0, 0
528-
br i1 %.fca.0.extract11, label %cond_580_case_1, label %cond_580_case_0
530+
br i1 %.fca.0.extract11, label %cond_583_case_1, label %cond_583_case_0
529531

530-
cond_580_case_1: ; preds = %alloca_block
532+
cond_583_case_1: ; preds = %alloca_block
531533
%1 = extractvalue { i1, { i1, i64, i1 } } %0, 1
532534
ret { i1, i64, i1 } %1
533535

534-
cond_580_case_0: ; preds = %alloca_block
536+
cond_583_case_0: ; preds = %alloca_block
535537
tail call void @panic(i32 1001, ptr nonnull @"e_Expected v.E6312129.0")
536538
unreachable
537539
}
@@ -546,8 +548,6 @@ declare void @___rp(i64, double, double) local_unnamed_addr
546548

547549
declare void @___rz(i64, double) local_unnamed_addr
548550

549-
declare void @___rpg(i64, i64, double, double) local_unnamed_addr
550-
551551
declare void @___rpp(i64, i64, double, double) local_unnamed_addr
552552

553553
declare i64 @___qalloc() local_unnamed_addr

0 commit comments

Comments
 (0)