From 318ad7bbe0b712c22a5bd358f77de26422d12cd4 Mon Sep 17 00:00:00 2001 From: Pat Gavlin Date: Tue, 25 Jul 2017 16:56:50 -0700 Subject: [PATCH] Admit additional `ADD` patterns in `GenTree:IsFieldAddr`. We already recognize `ADD(t, CNS_INT)` in this function. This change extends the relevant logic to `ADD(CNS_INT, t)` iff the first operand is a handle. --- src/jit/gentree.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/jit/gentree.cpp b/src/jit/gentree.cpp index c6e690d..29d8cef 100644 --- a/src/jit/gentree.cpp +++ b/src/jit/gentree.cpp @@ -15398,10 +15398,16 @@ bool GenTree::IsFieldAddr(Compiler* comp, GenTreePtr* pObj, GenTreePtr* pStatic, } else if (OperGet() == GT_ADD) { - // op1 should never be a field sequence (or any other kind of handle) - assert((gtOp.gtOp1->gtOper != GT_CNS_INT) || !gtOp.gtOp1->IsIconHandle()); - if (gtOp.gtOp2->OperGet() == GT_CNS_INT) + // If one operator is a field sequence/handle, the other operator must not also be a field sequence/handle. + if ((gtOp.gtOp1->OperGet() == GT_CNS_INT) && gtOp.gtOp1->IsIconHandle()) { + assert((gtOp.gtOp2->gtOper != GT_CNS_INT) || !gtOp.gtOp2->IsIconHandle()); + newFldSeq = gtOp.gtOp1->AsIntCon()->gtFieldSeq; + baseAddr = gtOp.gtOp2; + } + else if (gtOp.gtOp2->OperGet() == GT_CNS_INT) + { + assert((gtOp.gtOp1->gtOper != GT_CNS_INT) || !gtOp.gtOp1->IsIconHandle()); newFldSeq = gtOp.gtOp2->AsIntCon()->gtFieldSeq; baseAddr = gtOp.gtOp1; } -- 2.7.4