From 372e8f9b2b11dbf71403a1734d8ab905e8df4b71 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 bc880a5bf..588a5b9a6 100644 --- a/artiq/compiler/transforms/llvm_ir_generator.py +++ b/artiq/compiler/transforms/llvm_ir_generator.py @@ -849,6 +849,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)