From 7ae68c2a0b3e1c97feace9757248b4b5ff115022 Mon Sep 17 00:00:00 2001 From: Mike Danes Date: Fri, 20 Jan 2017 08:38:17 +0200 Subject: [PATCH] Comments --- src/jit/gtlist.h | 7 +++++++ src/jit/lower.cpp | 10 +++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/jit/gtlist.h b/src/jit/gtlist.h index fb6d8e8..2d9255b 100644 --- a/src/jit/gtlist.h +++ b/src/jit/gtlist.h @@ -146,6 +146,13 @@ GTNODE(LE , "<=" ,GenTreeOp ,0,GTK_BINOP|GTK_RE GTNODE(GE , ">=" ,GenTreeOp ,0,GTK_BINOP|GTK_RELOP) GTNODE(GT , ">" ,GenTreeOp ,0,GTK_BINOP|GTK_RELOP) #ifndef LEGACY_BACKEND +// These are similar to GT_EQ/GT_NE but they generate "test" instead of "cmp" instructions. +// Currently these are generated during lowering for code like ((x & y) eq|ne 0) only on +// XArch but ARM could too use these for the same purpose as there is a "tst" instruction. +// Note that the general case of comparing a register against 0 is handled directly by +// codegen which emits a "test reg, reg" instruction, that would be more difficult to do +// during lowering because the source operand is used twice so it has to be a lclvar. +// Because of this there is no need to also add GT_TEST_LT/LE/GE/GT opers. GTNODE(TEST_EQ , "testEQ" ,GenTreeOp ,0,GTK_BINOP|GTK_RELOP) GTNODE(TEST_NE , "testNE" ,GenTreeOp ,0,GTK_BINOP|GTK_RELOP) #endif diff --git a/src/jit/lower.cpp b/src/jit/lower.cpp index 2533782..7856519 100644 --- a/src/jit/lower.cpp +++ b/src/jit/lower.cpp @@ -1928,11 +1928,11 @@ GenTree* Lowering::LowerTailCallViaHelper(GenTreeCall* call, GenTree* callTarget // cmp - the compare node // // Notes: +// - Decomposes long comparisons that feed a GT_JTRUE (32 bit specific). +// - Ensures that we don't have a mix of int/long operands (XARCH specific). // - Narrow operands to enable memory operand containment (XARCH specific). // - Transform cmp(and(x, y), 0) into test(x, y) (XARCH specific but could // be used for ARM as well if support for GT_TEST_EQ/GT_TEST_NE is added). -// - Ensures that we don't have a mix of int/long operands (XARCH specific). -// - Decomposes long comparisons that feed a GT_JTRUE (32 bit specific). void Lowering::LowerCompare(GenTree* cmp) { @@ -1942,9 +1942,9 @@ void Lowering::LowerCompare(GenTree* cmp) if ((cmp->gtGetOp1()->TypeGet() == TYP_LONG) && BlockRange().TryGetUse(cmp, &cmpUse) && cmpUse.User()->OperIs(GT_JTRUE)) { - // For 32-bit targets any comparison that feeds a `GT_JTRUE` node must be lowered - // such that the liveness of the operands to the is properly visible to the rest - // of the backend. As such, a 64-bit comparison is lowered from something like this: + // For 32-bit targets any comparison that feeds a `GT_JTRUE` node must be lowered such that + // the liveness of the operands to the comparison is properly visible to the rest of the + // backend. As such, a 64-bit comparison is lowered from something like this: // // ------------ BB02 [004..014) -> BB02 (cond), preds={BB02,BB01} succs={BB03,BB02} // N001 ( 1, 1) [000006] ------------ t6 = lclVar int V02 loc0 u:5 $148 -- 2.7.4