diff --git a/sledge/src/llair/exp.ml b/sledge/src/llair/exp.ml index bff555aeb..34ed8888f 100644 --- a/sledge/src/llair/exp.ml +++ b/sledge/src/llair/exp.ml @@ -366,7 +366,11 @@ let typ_of = function let typ = typ_of let type_check e typ = - assert (Option.for_all ~f:(Typ.castable typ) (typ_of e)) + assert ( + Option.for_all ~f:(Typ.castable typ) (typ_of e) + || fail "%a@ : %a not <:@ %a" pp e Typ.pp + (Option.value_exn (typ_of e)) + Typ.pp typ ) let type_check2 e f typ = type_check e typ ; type_check f typ diff --git a/sledge/src/llair/frontend.ml b/sledge/src/llair/frontend.ml index b59b87e31..e565fef93 100644 --- a/sledge/src/llair/frontend.ml +++ b/sledge/src/llair/frontend.ml @@ -532,7 +532,11 @@ and xlate_opcode : x -> Llvm.llvalue -> Llvm.Opcode.t -> Exp.t = [%Trace.call fun {pf} -> pf "%i %a" i pp_llvalue (Llvm.operand llv i)] ; - let idx = xlate_rand i in + let idx = + Exp.convert ~dst:Typ.siz + ~src:(xlate_type x (Llvm.type_of (Llvm.operand llv i))) + (xlate_rand i) + in ( if i = 1 then let base = xlate_rand 0 in let lltyp = Llvm.type_of (Llvm.operand llv 0) in