From 7af41bd29ce966dea8d97ae3118699e6e6143611 Mon Sep 17 00:00:00 2001 From: whitequark Date: Mon, 21 Nov 2016 02:25:27 +0000 Subject: [PATCH] llvm_ir_generator: handle no-op coercions. --- artiq/compiler/transforms/llvm_ir_generator.py | 2 ++ artiq/test/lit/codegen/noop_coercion.py | 4 ++++ 2 files changed, 6 insertions(+) create mode 100644 artiq/test/lit/codegen/noop_coercion.py diff --git a/artiq/compiler/transforms/llvm_ir_generator.py b/artiq/compiler/transforms/llvm_ir_generator.py index 0a41479b8..09e62aab8 100644 --- a/artiq/compiler/transforms/llvm_ir_generator.py +++ b/artiq/compiler/transforms/llvm_ir_generator.py @@ -848,6 +848,8 @@ class LLVMIRGenerator: def process_Coerce(self, insn): typ, value_typ = insn.type, insn.value().type + if typ == value_typ: + return self.map(insn.value()) if builtins.is_int(typ) and builtins.is_float(value_typ): return self.llbuilder.fptosi(self.map(insn.value()), self.llty_of_type(typ), name=insn.name) diff --git a/artiq/test/lit/codegen/noop_coercion.py b/artiq/test/lit/codegen/noop_coercion.py new file mode 100644 index 000000000..df4ce830b --- /dev/null +++ b/artiq/test/lit/codegen/noop_coercion.py @@ -0,0 +1,4 @@ +# RUN: %python -m artiq.compiler.testbench.llvmgen %s + +def f(): + return float(1.0)