@@ -4276,28 +4276,24 @@ unsigned Compiler::gtSetEvalOrder(GenTree* tree)
4276
4276
case GT_IND:
4277
4277
case GT_BLK:
4278
4278
case GT_OBJ:
4279
-
4280
- // In an indirection, the destination address is evaluated prior to the source.
4281
- // If we have any side effects on the target indirection,
4282
- // we have to evaluate op1 first.
4283
- // However, if the LHS is a lclVar address, SSA relies on using evaluation order for its
4284
- // renaming, and therefore the RHS must be evaluated first.
4285
- // If we have an assignment involving a lclVar address, the LHS may be marked as having
4286
- // side-effects.
4287
- // However the side-effects won't require that we evaluate the LHS address first:
4288
- // - The GTF_GLOB_REF might have been conservatively set on a FIELD of a local.
4289
- // - The local might be address-exposed, but that side-effect happens at the actual assignment (not
4290
- // when its address is "evaluated") so it doesn't change the side effect to "evaluate" the address
4291
- // after the RHS (note that in this case it won't be renamed by SSA anyway, but the reordering is
4292
- // safe).
4279
+ {
4280
+ // In an ASG(IND(addr), ...), the "IND" is a pure syntactical element,
4281
+ // the actual indirection will only be realized at the point of the ASG
4282
+ // itself. As such, we can disard any side effects "induced" by it in
4283
+ // this logic.
4284
+ //
4285
+ // Note that for local "addr"s, liveness depends on seeing the defs and
4286
+ // uses in correct order, and so we MUST reverse the ASG in that case.
4293
4287
//
4294
- if (op1Val->AsIndir()->Addr()->IsLocalAddrExpr())
4288
+ GenTree* op1Addr = op1->AsIndir()->Addr();
4289
+
4290
+ if (op1Addr->IsLocalAddrExpr() || op1Addr->IsInvariant())
4295
4291
{
4296
4292
bReverseInAssignment = true;
4297
4293
tree->gtFlags |= GTF_REVERSE_OPS;
4298
4294
break;
4299
4295
}
4300
- if (op1Val->AsIndir()->Addr() ->gtFlags & GTF_ALL_EFFECT)
4296
+ if (op1Addr ->gtFlags & GTF_ALL_EFFECT)
4301
4297
{
4302
4298
break;
4303
4299
}
@@ -4314,7 +4310,7 @@ unsigned Compiler::gtSetEvalOrder(GenTree* tree)
4314
4310
{
4315
4311
break;
4316
4312
}
4317
-
4313
+ }
4318
4314
// fall through and set GTF_REVERSE_OPS
4319
4315
FALLTHROUGH;
4320
4316
0 commit comments