@@ -2442,11 +2442,18 @@ static Value *emit_bitsunion_compare(jl_codectx_t &ctx, const jl_cgval_t &arg1,
2442
2442
{
2443
2443
assert (jl_egal (arg1.typ , arg2.typ ) && arg1.TIndex && arg2.TIndex && jl_is_uniontype (arg1.typ ) && " unimplemented" );
2444
2444
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 ));
2445
2450
BasicBlock *defaultBB = BasicBlock::Create (jl_LLVMContext, " unionbits_is_boxed" , ctx.f );
2446
2451
SwitchInst *switchInst = ctx.builder .CreateSwitch (tindex, defaultBB);
2447
2452
BasicBlock *postBB = BasicBlock::Create (jl_LLVMContext, " post_unionbits_is" , ctx.f );
2448
2453
ctx.builder .SetInsertPoint (postBB);
2449
2454
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 ());
2450
2457
unsigned counter = 0 ;
2451
2458
bool allunboxed = for_each_uniontype_small (
2452
2459
[&](unsigned idx, jl_datatype_t *jt) {
@@ -2470,7 +2477,7 @@ static Value *emit_bitsunion_compare(jl_codectx_t &ctx, const jl_cgval_t &arg1,
2470
2477
ctx.builder .CreateCall (trap_func);
2471
2478
ctx.builder .CreateUnreachable ();
2472
2479
ctx.builder .SetInsertPoint (postBB);
2473
- return ctx. builder . CreateAnd ( phi, ctx. builder . CreateICmpEQ (arg1. TIndex , arg2. TIndex )) ;
2480
+ return phi;
2474
2481
}
2475
2482
2476
2483
static Value *emit_bits_compare (jl_codectx_t &ctx, jl_cgval_t arg1, jl_cgval_t arg2)
0 commit comments