diff --git a/source/compiler/qsc_circuit/src/rir_to_circuit.rs b/source/compiler/qsc_circuit/src/rir_to_circuit.rs index 9fec71e3dc..0a5b36a6ac 100644 --- a/source/compiler/qsc_circuit/src/rir_to_circuit.rs +++ b/source/compiler/qsc_circuit/src/rir_to_circuit.rs @@ -365,6 +365,10 @@ fn process_variables( Instruction::LogicalNot(operand, variable) => { process_logical_not_variables(&mut state.variables, operand, *variable)?; } + Instruction::Convert(operand, variable) => { + let expr = expr_from_operand(&state.variables, operand)?; + store_expr_in_variable(&mut state.variables, *variable, expr)?; + } instruction @ (Instruction::Store(..) | Instruction::BitwiseNot(..)) => { return Err(Error::UnsupportedFeature(format!( "unsupported instruction in block: {instruction:?}" diff --git a/source/compiler/qsc_codegen/src/qir.rs b/source/compiler/qsc_codegen/src/qir.rs index 5dd25daa36..59a307cade 100644 --- a/source/compiler/qsc_codegen/src/qir.rs +++ b/source/compiler/qsc_codegen/src/qir.rs @@ -304,6 +304,9 @@ impl ToQir for rir::Instruction { rir::Instruction::Call(call_id, args, output, _) => { call_to_qir(args, *call_id, *output, program) } + rir::Instruction::Convert(operand, variable) => { + convert_to_qir(operand, *variable, program) + } rir::Instruction::Fadd(lhs, rhs, variable) => { fbinop_to_qir("fadd", lhs, rhs, *variable, program) } @@ -356,6 +359,31 @@ impl ToQir for rir::Instruction { } } +fn convert_to_qir( + operand: &rir::Operand, + variable: rir::Variable, + program: &rir::Program, +) -> String { + let operand_ty = get_value_ty(operand); + let var_ty = get_variable_ty(variable); + assert_ne!( + operand_ty, var_ty, + "input/output types ({operand_ty}, {var_ty}) should not match in convert" + ); + + let convert_instr = match (operand_ty, var_ty) { + ("i64", "double") => "sitofp i64", + ("double", "i64") => "fptosi double", + _ => panic!("unsupported conversion from {operand_ty} to {var_ty} in convert instruction"), + }; + + format!( + " {} = {convert_instr} {} to {var_ty}", + ToQir::::to_qir(&variable.variable_id, program), + get_value_as_str(operand, program), + ) +} + fn logical_not_to_qir( value: &rir::Operand, variable: rir::Variable, diff --git a/source/compiler/qsc_codegen/src/qir/instruction_tests/double.rs b/source/compiler/qsc_codegen/src/qir/instruction_tests/double.rs index 1d6d90b77f..bdcfdbaa43 100644 --- a/source/compiler/qsc_codegen/src/qir/instruction_tests/double.rs +++ b/source/compiler/qsc_codegen/src/qir/instruction_tests/double.rs @@ -477,3 +477,31 @@ fn fsub_double_variables() { ); expect![" %var_0 = fsub double %var_1, %var_2"].assert_eq(&inst.to_qir(&Program::default())); } + +#[test] +fn convert_double_literal_to_integer() { + let inst = Instruction::Convert( + Operand::Literal(Literal::Double(PI)), + Variable { + variable_id: VariableId(0), + ty: Ty::Integer, + }, + ); + expect![" %var_0 = fptosi double 3.141592653589793 to i64"] + .assert_eq(&inst.to_qir(&Program::default())); +} + +#[test] +fn convert_double_variable_to_integer() { + let inst = Instruction::Convert( + Operand::Variable(Variable { + variable_id: VariableId(1), + ty: Ty::Double, + }), + Variable { + variable_id: VariableId(0), + ty: Ty::Integer, + }, + ); + expect![" %var_0 = fptosi double %var_1 to i64"].assert_eq(&inst.to_qir(&Program::default())); +} diff --git a/source/compiler/qsc_codegen/src/qir/instruction_tests/int.rs b/source/compiler/qsc_codegen/src/qir/instruction_tests/int.rs index abcb354ef9..6c0031e55d 100644 --- a/source/compiler/qsc_codegen/src/qir/instruction_tests/int.rs +++ b/source/compiler/qsc_codegen/src/qir/instruction_tests/int.rs @@ -557,3 +557,31 @@ fn sub_integer_variables() { ); expect![" %var_0 = sub i64 %var_1, %var_2"].assert_eq(&inst.to_qir(&rir::Program::default())); } + +#[test] +fn convert_integer_literal_to_double() { + let inst = rir::Instruction::Convert( + rir::Operand::Literal(rir::Literal::Integer(2)), + rir::Variable { + variable_id: rir::VariableId(0), + ty: rir::Ty::Double, + }, + ); + expect![" %var_0 = sitofp i64 2 to double"].assert_eq(&inst.to_qir(&rir::Program::default())); +} + +#[test] +fn convert_integer_variable_to_double() { + let inst = rir::Instruction::Convert( + rir::Operand::Variable(rir::Variable { + variable_id: rir::VariableId(1), + ty: rir::Ty::Integer, + }), + rir::Variable { + variable_id: rir::VariableId(0), + ty: rir::Ty::Double, + }, + ); + expect![" %var_0 = sitofp i64 %var_1 to double"] + .assert_eq(&inst.to_qir(&rir::Program::default())); +} diff --git a/source/compiler/qsc_partial_eval/src/lib.rs b/source/compiler/qsc_partial_eval/src/lib.rs index 1cf0caf18d..da773d12f3 100644 --- a/source/compiler/qsc_partial_eval/src/lib.rs +++ b/source/compiler/qsc_partial_eval/src/lib.rs @@ -1793,6 +1793,14 @@ impl<'a> PartialEvaluator<'a> { callee_expr_span, )) } + "IntAsDouble" => { + let variable_id = self.resource_manager.next_var(); + self.convert_value(&args_value, rir::Variable::new_double(variable_id)) + } + "Truncate" => { + let variable_id = self.resource_manager.next_var(); + self.convert_value(&args_value, rir::Variable::new_integer(variable_id)) + } _ => self.eval_expr_call_to_intrinsic_qis( store_item_id, callable_decl, @@ -3156,6 +3164,20 @@ impl<'a> PartialEvaluator<'a> { } } + fn convert_value( + &mut self, + args_value: &Value, + variable: rir::Variable, + ) -> Result { + let instruction = + Instruction::Convert(self.map_eval_value_to_rir_operand(args_value), variable); + let current_block = self.get_current_rir_block_mut(); + current_block.0.push(instruction); + Ok(Value::Var( + map_rir_var_to_eval_var(variable).expect("variable should convert"), + )) + } + fn update_bindings(&mut self, lhs_expr_id: ExprId, rhs_value: Value) -> Result<(), Error> { let lhs_expr = self.get_expr(lhs_expr_id); match (&lhs_expr.kind, rhs_value) { diff --git a/source/compiler/qsc_partial_eval/src/tests/misc.rs b/source/compiler/qsc_partial_eval/src/tests/misc.rs index 6bfbbdc9c4..b2d68d442f 100644 --- a/source/compiler/qsc_partial_eval/src/tests/misc.rs +++ b/source/compiler/qsc_partial_eval/src/tests/misc.rs @@ -718,3 +718,85 @@ fn string_concatenation_with_side_effects_captures_side_effects() { Return"#]], ); } + +#[test] +fn integer_to_double_conversion() { + let program = get_rir_program(indoc! { + r#" + namespace Test { + @EntryPoint() + operation Main() : Double { + let i = {use q = Qubit(); if MResetZ(q) == One { 42 } else { 0 }}; + let d = Std.Convert.IntAsDouble(i); + return d; + } + } + "#, + }); + + assert_blocks( + &program, + &expect![[r#" + Blocks: + Block 0:Block: + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) + Variable(1, Boolean) = Store Variable(0, Boolean) + Branch Variable(1, Boolean), 2, 3 + Block 1:Block: + Variable(3, Integer) = Store Variable(2, Integer) + Variable(4, Integer) = Store Variable(3, Integer) + Variable(5, Double) = Convert Variable(4, Integer) + Variable(6, Double) = Store Variable(5, Double) + Call id(4), args( Variable(6, Double), Tag(0, 3), ) + Return + Block 2:Block: + Variable(2, Integer) = Store Integer(42) + Jump(1) + Block 3:Block: + Variable(2, Integer) = Store Integer(0) + Jump(1)"#]], + ); +} + +#[test] +fn double_to_integer_conversion() { + let program = get_rir_program(indoc! { + r#" + namespace Test { + @EntryPoint() + operation Main() : Int { + let d = {use q = Qubit(); if MResetZ(q) == One { 42.1 } else { 0.0 }}; + let i = Std.Math.Truncate(d); + return i; + } + } + "#, + }); + + assert_blocks( + &program, + &expect![[r#" + Blocks: + Block 0:Block: + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) + Variable(1, Boolean) = Store Variable(0, Boolean) + Branch Variable(1, Boolean), 2, 3 + Block 1:Block: + Variable(3, Double) = Store Variable(2, Double) + Variable(4, Double) = Store Variable(3, Double) + Variable(5, Integer) = Convert Variable(4, Double) + Variable(6, Integer) = Store Variable(5, Integer) + Call id(4), args( Variable(6, Integer), Tag(0, 3), ) + Return + Block 2:Block: + Variable(2, Double) = Store Double(42.1) + Jump(1) + Block 3:Block: + Variable(2, Double) = Store Double(0) + Jump(1)"#]], + ); +} diff --git a/source/compiler/qsc_rir/src/passes/ssa_check.rs b/source/compiler/qsc_rir/src/passes/ssa_check.rs index 6aefeaa0ed..f94557a313 100644 --- a/source/compiler/qsc_rir/src/passes/ssa_check.rs +++ b/source/compiler/qsc_rir/src/passes/ssa_check.rs @@ -149,6 +149,7 @@ fn get_variable_uses(program: &Program) -> IndexMap { add_use(var.variable_id, block_id, idx); } @@ -215,7 +216,8 @@ fn get_variable_uses(program: &Program) -> IndexMap { + | Instruction::BitwiseXor(Operand::Literal(_), Operand::Literal(_), _) + | Instruction::Convert(Operand::Literal(_), _) => { panic!("{block_id:?}, instruction {idx} has no variables: {instr}") } diff --git a/source/compiler/qsc_rir/src/passes/ssa_transform.rs b/source/compiler/qsc_rir/src/passes/ssa_transform.rs index b5d872b81a..9992e70122 100644 --- a/source/compiler/qsc_rir/src/passes/ssa_transform.rs +++ b/source/compiler/qsc_rir/src/passes/ssa_transform.rs @@ -228,6 +228,11 @@ fn map_variable_use_in_block(block: &mut Block, var_map: &mut FxHashMap { + *operand = operand.mapped(var_map); + *var = var.map_to_variable(var_map); + } + // Phi nodes are handled separately in the SSA transformation, but need to be passed through // like the unconditional terminators. Instruction::Phi(..) | Instruction::Jump(..) | Instruction::Return => {} diff --git a/source/compiler/qsc_rir/src/passes/type_check.rs b/source/compiler/qsc_rir/src/passes/type_check.rs index ade58bdca1..ed7c61cf35 100644 --- a/source/compiler/qsc_rir/src/passes/type_check.rs +++ b/source/compiler/qsc_rir/src/passes/type_check.rs @@ -59,7 +59,7 @@ fn check_instr_types(program: &Program, instr: &Instruction) { } } - Instruction::Jump(_) | Instruction::Return => {} + Instruction::Convert(_, _) | Instruction::Jump(_) | Instruction::Return => {} } } diff --git a/source/compiler/qsc_rir/src/rir.rs b/source/compiler/qsc_rir/src/rir.rs index 46e63dfe8c..d9a4320f6c 100644 --- a/source/compiler/qsc_rir/src/rir.rs +++ b/source/compiler/qsc_rir/src/rir.rs @@ -346,6 +346,7 @@ pub enum Instruction { BitwiseOr(Operand, Operand, Variable), BitwiseXor(Operand, Operand, Variable), Phi(Vec<(Operand, BlockId)>, Variable), + Convert(Operand, Variable), Return, } @@ -532,6 +533,10 @@ impl Display for Instruction { Self::Phi(args, variable) => { write_phi_instruction(f, args, *variable)?; } + Self::Convert(operand, variable) => { + let mut indent = set_indentation(indented(f), 0); + write!(indent, "{variable} = Convert {operand}")?; + } Self::Return => write!(f, "Return")?, } Ok(()) diff --git a/source/compiler/qsc_rir/src/utils.rs b/source/compiler/qsc_rir/src/utils.rs index 8da2cfe79e..4a4f6aecbb 100644 --- a/source/compiler/qsc_rir/src/utils.rs +++ b/source/compiler/qsc_rir/src/utils.rs @@ -78,6 +78,7 @@ pub fn get_variable_assignments(program: &Program) -> IndexMap 5.0, count < 5.0, count >= 10.0, count == 10.0, count != 10.0); + let countInteger = Std.Math.Truncate(count); + let countIntegerAsDouble = Std.Convert.IntAsDouble(countInteger); + return (count, count > 5.0, count < 5.0, count >= 10.0, count == 10.0, count != 10.0, countInteger, countIntegerAsDouble); } } diff --git a/source/pip/tests-integration/resources/adaptive_rif/output/Doubles.ll b/source/pip/tests-integration/resources/adaptive_rif/output/Doubles.ll index b9f1cea802..fe04e081c2 100644 --- a/source/pip/tests-integration/resources/adaptive_rif/output/Doubles.ll +++ b/source/pip/tests-integration/resources/adaptive_rif/output/Doubles.ll @@ -8,6 +8,8 @@ @4 = internal constant [6 x i8] c"4_t3b\00" @5 = internal constant [6 x i8] c"5_t4b\00" @6 = internal constant [6 x i8] c"6_t5b\00" +@7 = internal constant [6 x i8] c"7_t6i\00" +@8 = internal constant [6 x i8] c"8_t7d\00" define i64 @ENTRYPOINT__main() #0 { block_0: @@ -20,146 +22,150 @@ block_1: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) br label %block_2 block_2: - %var_72 = phi double [0.0, %block_0], [1.0, %block_1] + %var_76 = phi double [0.0, %block_0], [1.0, %block_1] call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) %var_4 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 1 to %Result*)) br i1 %var_4, label %block_3, label %block_4 block_3: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) - %var_6 = fadd double %var_72, 1.0 + %var_6 = fadd double %var_76, 1.0 %var_7 = fmul double %var_6, 1.0 %var_8 = fsub double %var_7, 1.0 %var_9 = fdiv double %var_8, 1.0 %var_10 = fadd double %var_9, 1.0 br label %block_4 block_4: - %var_73 = phi double [%var_72, %block_2], [%var_10, %block_3] + %var_77 = phi double [%var_76, %block_2], [%var_10, %block_3] call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 2 to %Result*)) %var_11 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 2 to %Result*)) br i1 %var_11, label %block_5, label %block_6 block_5: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) - %var_13 = fadd double %var_73, 1.0 + %var_13 = fadd double %var_77, 1.0 %var_14 = fmul double %var_13, 1.0 %var_15 = fsub double %var_14, 1.0 %var_16 = fdiv double %var_15, 1.0 %var_17 = fadd double %var_16, 1.0 br label %block_6 block_6: - %var_74 = phi double [%var_73, %block_4], [%var_17, %block_5] + %var_78 = phi double [%var_77, %block_4], [%var_17, %block_5] call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 3 to %Result*)) %var_18 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 3 to %Result*)) br i1 %var_18, label %block_7, label %block_8 block_7: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) - %var_20 = fadd double %var_74, 1.0 + %var_20 = fadd double %var_78, 1.0 %var_21 = fmul double %var_20, 1.0 %var_22 = fsub double %var_21, 1.0 %var_23 = fdiv double %var_22, 1.0 %var_24 = fadd double %var_23, 1.0 br label %block_8 block_8: - %var_75 = phi double [%var_74, %block_6], [%var_24, %block_7] + %var_79 = phi double [%var_78, %block_6], [%var_24, %block_7] call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 4 to %Result*)) %var_25 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 4 to %Result*)) br i1 %var_25, label %block_9, label %block_10 block_9: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) - %var_27 = fadd double %var_75, 1.0 + %var_27 = fadd double %var_79, 1.0 %var_28 = fmul double %var_27, 1.0 %var_29 = fsub double %var_28, 1.0 %var_30 = fdiv double %var_29, 1.0 %var_31 = fadd double %var_30, 1.0 br label %block_10 block_10: - %var_76 = phi double [%var_75, %block_8], [%var_31, %block_9] + %var_80 = phi double [%var_79, %block_8], [%var_31, %block_9] call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 5 to %Result*)) %var_32 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 5 to %Result*)) br i1 %var_32, label %block_11, label %block_12 block_11: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) - %var_34 = fadd double %var_76, 1.0 + %var_34 = fadd double %var_80, 1.0 %var_35 = fmul double %var_34, 1.0 %var_36 = fsub double %var_35, 1.0 %var_37 = fdiv double %var_36, 1.0 %var_38 = fadd double %var_37, 1.0 br label %block_12 block_12: - %var_77 = phi double [%var_76, %block_10], [%var_38, %block_11] + %var_81 = phi double [%var_80, %block_10], [%var_38, %block_11] call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 6 to %Result*)) %var_39 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 6 to %Result*)) br i1 %var_39, label %block_13, label %block_14 block_13: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) - %var_41 = fadd double %var_77, 1.0 + %var_41 = fadd double %var_81, 1.0 %var_42 = fmul double %var_41, 1.0 %var_43 = fsub double %var_42, 1.0 %var_44 = fdiv double %var_43, 1.0 %var_45 = fadd double %var_44, 1.0 br label %block_14 block_14: - %var_78 = phi double [%var_77, %block_12], [%var_45, %block_13] + %var_82 = phi double [%var_81, %block_12], [%var_45, %block_13] call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 7 to %Result*)) %var_46 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 7 to %Result*)) br i1 %var_46, label %block_15, label %block_16 block_15: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) - %var_48 = fadd double %var_78, 1.0 + %var_48 = fadd double %var_82, 1.0 %var_49 = fmul double %var_48, 1.0 %var_50 = fsub double %var_49, 1.0 %var_51 = fdiv double %var_50, 1.0 %var_52 = fadd double %var_51, 1.0 br label %block_16 block_16: - %var_79 = phi double [%var_78, %block_14], [%var_52, %block_15] + %var_83 = phi double [%var_82, %block_14], [%var_52, %block_15] call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 8 to %Result*)) %var_53 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 8 to %Result*)) br i1 %var_53, label %block_17, label %block_18 block_17: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) - %var_55 = fadd double %var_79, 1.0 + %var_55 = fadd double %var_83, 1.0 %var_56 = fmul double %var_55, 1.0 %var_57 = fsub double %var_56, 1.0 %var_58 = fdiv double %var_57, 1.0 %var_59 = fadd double %var_58, 1.0 br label %block_18 block_18: - %var_80 = phi double [%var_79, %block_16], [%var_59, %block_17] + %var_84 = phi double [%var_83, %block_16], [%var_59, %block_17] call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 9 to %Result*)) %var_60 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 9 to %Result*)) br i1 %var_60, label %block_19, label %block_20 block_19: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) - %var_62 = fadd double %var_80, 1.0 + %var_62 = fadd double %var_84, 1.0 %var_63 = fmul double %var_62, 1.0 %var_64 = fsub double %var_63, 1.0 %var_65 = fdiv double %var_64, 1.0 %var_66 = fadd double %var_65, 1.0 br label %block_20 block_20: - %var_81 = phi double [%var_80, %block_18], [%var_66, %block_19] + %var_85 = phi double [%var_84, %block_18], [%var_66, %block_19] call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 0 to %Qubit*)) - %var_67 = fcmp ogt double %var_81, 5.0 - %var_68 = fcmp olt double %var_81, 5.0 - %var_69 = fcmp oge double %var_81, 10.0 - %var_70 = fcmp oeq double %var_81, 10.0 - %var_71 = fcmp one double %var_81, 10.0 - call void @__quantum__rt__tuple_record_output(i64 6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @0, i64 0, i64 0)) - call void @__quantum__rt__double_record_output(double %var_81, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @1, i64 0, i64 0)) - call void @__quantum__rt__bool_record_output(i1 %var_67, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @2, i64 0, i64 0)) - call void @__quantum__rt__bool_record_output(i1 %var_68, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @3, i64 0, i64 0)) - call void @__quantum__rt__bool_record_output(i1 %var_69, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @4, i64 0, i64 0)) - call void @__quantum__rt__bool_record_output(i1 %var_70, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @5, i64 0, i64 0)) - call void @__quantum__rt__bool_record_output(i1 %var_71, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @6, i64 0, i64 0)) + %var_67 = fptosi double %var_85 to i64 + %var_69 = sitofp i64 %var_67 to double + %var_71 = fcmp ogt double %var_85, 5.0 + %var_72 = fcmp olt double %var_85, 5.0 + %var_73 = fcmp oge double %var_85, 10.0 + %var_74 = fcmp oeq double %var_85, 10.0 + %var_75 = fcmp one double %var_85, 10.0 + call void @__quantum__rt__tuple_record_output(i64 8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__double_record_output(double %var_85, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @1, i64 0, i64 0)) + call void @__quantum__rt__bool_record_output(i1 %var_71, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @2, i64 0, i64 0)) + call void @__quantum__rt__bool_record_output(i1 %var_72, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @3, i64 0, i64 0)) + call void @__quantum__rt__bool_record_output(i1 %var_73, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @4, i64 0, i64 0)) + call void @__quantum__rt__bool_record_output(i1 %var_74, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @5, i64 0, i64 0)) + call void @__quantum__rt__bool_record_output(i1 %var_75, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @6, i64 0, i64 0)) + call void @__quantum__rt__int_record_output(i64 %var_67, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @7, i64 0, i64 0)) + call void @__quantum__rt__double_record_output(double %var_69, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @8, i64 0, i64 0)) ret i64 0 } @@ -179,6 +185,8 @@ declare void @__quantum__rt__double_record_output(double, i8*) declare void @__quantum__rt__bool_record_output(i1, i8*) +declare void @__quantum__rt__int_record_output(i64, i8*) + attributes #0 = { "entry_point" "output_labeling_schema" "qir_profiles"="adaptive_profile" "required_num_qubits"="1" "required_num_results"="10" } attributes #1 = { "irreversible" } diff --git a/source/pip/tests-integration/resources/adaptive_rif/output/Doubles.out b/source/pip/tests-integration/resources/adaptive_rif/output/Doubles.out index 0cf7e1b9dd..1e75619beb 100644 --- a/source/pip/tests-integration/resources/adaptive_rif/output/Doubles.out +++ b/source/pip/tests-integration/resources/adaptive_rif/output/Doubles.out @@ -4,11 +4,13 @@ METADATA output_labeling_schema METADATA qir_profiles adaptive_profile METADATA required_num_qubits 1 METADATA required_num_results 10 -OUTPUT TUPLE 6 0_t +OUTPUT TUPLE 8 0_t OUTPUT DOUBLE 10.0 1_t0d OUTPUT BOOL true 2_t1b OUTPUT BOOL false 3_t2b OUTPUT BOOL true 4_t3b OUTPUT BOOL true 5_t4b OUTPUT BOOL false 6_t5b +OUTPUT INT 10 7_t6i +OUTPUT DOUBLE 10.0 8_t7d END 0