@@ -2228,6 +2228,9 @@ static jl_cgval_t typed_load(jl_codectx_t &ctx, Value *ptr, Value *idx_0based, j
2228
2228
}
2229
2229
Value *instr = nullptr ;
2230
2230
if (!isboxed && jl_is_genericmemoryref_type (jltype)) {
2231
+ // We don't specify the stronger expected memory ordering here because of fears it may interfere with vectorization and other optimizations
2232
+ // if (Order == AtomicOrdering::NotAtomic)
2233
+ // Order = AtomicOrdering::Monotonic;
2231
2234
// load these FCA as individual fields, so LLVM does not need to split them later
2232
2235
Value *fld0 = ctx.builder .CreateStructGEP (elty, ptr, 0 );
2233
2236
LoadInst *load0 = ctx.builder .CreateAlignedLoad (elty->getStructElementType (0 ), fld0, Align (alignment), false );
@@ -2403,11 +2406,26 @@ static jl_cgval_t typed_store(jl_codectx_t &ctx,
2403
2406
instr = load;
2404
2407
}
2405
2408
if (r) {
2406
- StoreInst *store = ctx.builder .CreateAlignedStore (r, ptr, Align (alignment));
2407
- store->setOrdering (Order == AtomicOrdering::NotAtomic && isboxed ? AtomicOrdering::Release : Order);
2408
2409
jl_aliasinfo_t ai = jl_aliasinfo_t::fromTBAA (ctx, tbaa);
2409
2410
ai.noalias = MDNode::concatenate (aliasscope, ai.noalias );
2410
- ai.decorateInst (store);
2411
+ if (false && !isboxed && Order == AtomicOrdering::NotAtomic && jl_is_genericmemoryref_type (jltype)) {
2412
+ // if enabled, store these FCA as individual fields, so LLVM does not need to split them later and they can use release ordering
2413
+ assert (r->getType () == ctx.types ().T_jlgenericmemory );
2414
+ Value *f1 = ctx.builder .CreateExtractValue (r, 0 );
2415
+ Value *f2 = ctx.builder .CreateExtractValue (r, 1 );
2416
+ static_assert (offsetof (jl_genericmemoryref_t , ptr_or_offset) == 0 , " wrong field order" );
2417
+ StoreInst *store = ctx.builder .CreateAlignedStore (f1, ctx.builder .CreateStructGEP (ctx.types ().T_jlgenericmemory , ptr, 0 ), Align (alignment));
2418
+ store->setOrdering (AtomicOrdering::Release);
2419
+ ai.decorateInst (store);
2420
+ store = ctx.builder .CreateAlignedStore (f2, ctx.builder .CreateStructGEP (ctx.types ().T_jlgenericmemory , ptr, 1 ), Align (alignment));
2421
+ store->setOrdering (AtomicOrdering::Release);
2422
+ ai.decorateInst (store);
2423
+ }
2424
+ else {
2425
+ StoreInst *store = ctx.builder .CreateAlignedStore (r, ptr, Align (alignment));
2426
+ store->setOrdering (Order == AtomicOrdering::NotAtomic && isboxed ? AtomicOrdering::Release : Order);
2427
+ ai.decorateInst (store);
2428
+ }
2411
2429
}
2412
2430
else {
2413
2431
assert (Order == AtomicOrdering::NotAtomic && !isboxed && rhs.typ == jltype);
@@ -4435,10 +4453,11 @@ static jl_cgval_t emit_new_struct(jl_codectx_t &ctx, jl_value_t *ty, size_t narg
4435
4453
for (size_t i = nargs; i < nf; i++) {
4436
4454
if (!jl_field_isptr (sty, i) && jl_is_uniontype (jl_field_type (sty, i))) {
4437
4455
jl_aliasinfo_t ai = jl_aliasinfo_t::fromTBAA (ctx, strctinfo.tbaa );
4438
- ai. decorateInst ( ctx.builder .CreateAlignedStore (
4456
+ auto *store = ctx.builder .CreateAlignedStore (
4439
4457
ConstantInt::get (getInt8Ty (ctx.builder .getContext ()), 0 ),
4440
4458
emit_ptrgep (ctx, strct, jl_field_offset (sty, i) + jl_field_size (sty, i) - 1 ),
4441
- Align (1 )));
4459
+ Align (1 ));
4460
+ ai.decorateInst (store);
4442
4461
}
4443
4462
}
4444
4463
// TODO: verify that nargs <= nf (currently handled by front-end)
0 commit comments