@@ -2442,11 +2442,18 @@ static Value *emit_bitsunion_compare(jl_codectx_t &ctx, const jl_cgval_t &arg1,
24422442{
24432443 assert (jl_egal (arg1.typ , arg2.typ ) && arg1.TIndex && arg2.TIndex && jl_is_uniontype (arg1.typ ) && " unimplemented" );
24442444 Value *tindex = arg1.TIndex ;
2445+ tindex = ctx.builder .CreateAnd (tindex, ConstantInt::get (T_int8, 0x7f ));
2446+ Value *tindex2 = arg2.TIndex ;
2447+ tindex2 = ctx.builder .CreateAnd (tindex2, ConstantInt::get (T_int8, 0x7f ));
2448+ Value *typeeq = ctx.builder .CreateICmpEQ (tindex, tindex2);
2449+ tindex = ctx.builder .CreateSelect (typeeq, tindex, ConstantInt::get (T_int8, 0x00 ));
24452450 BasicBlock *defaultBB = BasicBlock::Create (jl_LLVMContext, " unionbits_is_boxed" , ctx.f );
24462451 SwitchInst *switchInst = ctx.builder .CreateSwitch (tindex, defaultBB);
24472452 BasicBlock *postBB = BasicBlock::Create (jl_LLVMContext, " post_unionbits_is" , ctx.f );
24482453 ctx.builder .SetInsertPoint (postBB);
24492454 PHINode *phi = ctx.builder .CreatePHI (T_int1, 2 );
2455+ switchInst->addCase (ConstantInt::get (T_int8, 0 ), postBB);
2456+ phi->addIncoming (ConstantInt::get (T_int1, 0 ), switchInst->getParent ());
24502457 unsigned counter = 0 ;
24512458 bool allunboxed = for_each_uniontype_small (
24522459 [&](unsigned idx, jl_datatype_t *jt) {
@@ -2470,7 +2477,7 @@ static Value *emit_bitsunion_compare(jl_codectx_t &ctx, const jl_cgval_t &arg1,
24702477 ctx.builder .CreateCall (trap_func);
24712478 ctx.builder .CreateUnreachable ();
24722479 ctx.builder .SetInsertPoint (postBB);
2473- return ctx. builder . CreateAnd ( phi, ctx. builder . CreateICmpEQ (arg1. TIndex , arg2. TIndex )) ;
2480+ return phi;
24742481}
24752482
24762483static Value *emit_bits_compare (jl_codectx_t &ctx, jl_cgval_t arg1, jl_cgval_t arg2)
0 commit comments