open-standards/wai/quantum-conformance/formats/qir/computed.ll
Transaction Science 5fe6f317c1 quantum-conformance: other formats, natively and under wasm32-wasip2
wai/quantum-conformance/formats/ holds a module for each construct, each
with the program it must read to (a reference held by the equivalence
ladder), the outcomes it gives, a round trip back to its format, the
formats it writes to, and every refusal with its code and its place: the
QIR specification's two example programs, every intrinsic, a QIR 1 module
with typed pointers, the profiles' refusals; jeff modules built field by
field from the schema; the jeff project's own structured benchmarks and
examples, unchanged; and OpenQASM sources written to each format, the QIR
written pinned by its BLAKE3. CI runs it in wai-quantum-formats.yml, with
the readers' and writers' unit tests.

The jeff reader now converts integers to floats and floats to integers,
and a QIR conversion is checked against the type it gives.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 07:16:32 -04:00

35 lines
1.5 KiB
LLVM

; Adaptive: an angle computed from constants under float_computations, and a branch on two results combined by i1 logic: result 2 is 1 exactly when results 0 and 1 agree.
define i64 @main() #0 {
entry:
call void @__quantum__rt__initialize(ptr null)
%a = fadd double 0.25, 0.5
%b = fmul double %a, 2.0
call void @__quantum__qis__ry__body(double %b, ptr null)
call void @__quantum__qis__h__body(ptr inttoptr (i64 1 to ptr))
call void @__quantum__qis__mz__body(ptr null, ptr writeonly null)
call void @__quantum__qis__mz__body(ptr inttoptr (i64 1 to ptr), ptr writeonly inttoptr (i64 1 to ptr))
%r0 = call i1 @__quantum__rt__read_result(ptr readonly null)
%r1 = call i1 @__quantum__rt__read_result(ptr readonly inttoptr (i64 1 to ptr))
%x = xor i1 %r0, %r1
%n = xor i1 %x, true
br i1 %n, label %same, label %out
same:
call void @__quantum__qis__x__body(ptr inttoptr (i64 2 to ptr))
br label %out
out:
call void @__quantum__qis__mz__body(ptr inttoptr (i64 2 to ptr), ptr writeonly inttoptr (i64 2 to ptr))
ret i64 0
}
attributes #0 = { "entry_point" "qir_profiles"="adaptive_profile" "output_labeling_schema"="labels" "required_num_qubits"="3" "required_num_results"="3" }
attributes #1 = { "irreversible" }
!llvm.module.flags = !{!0, !1, !2, !3, !4, !5}
!0 = !{i32 1, !"qir_major_version", i32 2}
!1 = !{i32 7, !"qir_minor_version", i32 1}
!2 = !{i32 1, !"dynamic_qubit_management", i1 false}
!3 = !{i32 1, !"dynamic_result_management", i1 false}
!4 = !{i32 5, !"float_computations", !10}
!5 = !{i32 1, !"backwards_branching", i2 0}
!10 = !{!"double"}