Address CR feedback
authorMike Danes <onemihaid@hotmail.com>
Fri, 20 Jan 2017 18:34:00 +0000 (20:34 +0200)
committerMike Danes <onemihaid@hotmail.com>
Fri, 20 Jan 2017 18:34:00 +0000 (20:34 +0200)
- rename genTypeValueFitsIn
- use pointer to pointer instead of reference to pointer

src/jit/codegenxarch.cpp
src/jit/compiler.hpp
src/jit/lower.cpp

index b504ece..d018241 100644 (file)
@@ -6190,7 +6190,7 @@ void CodeGen::genCompareInt(GenTreePtr treeNode)
     // If op2 is smaller then it cannot be in memory, we're probably missing a cast
     assert((genTypeSize(op2Type) >= genTypeSize(type)) || !op2->isUsedFromMemory());
     // If op2 is a constant then it should fit in the common type
-    assert(!op2->IsCnsIntOrI() || genTypeValueFitsIn(op2->AsIntCon()->IconValue(), type));
+    assert(!op2->IsCnsIntOrI() || genTypeCanRepresentValue(type, op2->AsIntCon()->IconValue()));
 
     getEmitter()->emitInsBinary(ins, emitTypeSize(type), op1, op2);
 
index 3439736..82a1c75 100644 (file)
@@ -501,7 +501,7 @@ inline regNumber genRegNumFromMask(regMaskTP mask)
 }
 
 //------------------------------------------------------------------------------
-// genTypeValueFitsIn : Checks if a value can be represented by a given type.
+// genTypeCanRepresentValue: Checks if a value can be represented by a given type.
 //
 // Arguments:
 //    value - the value to check
@@ -515,7 +515,7 @@ inline regNumber genRegNumFromMask(regMaskTP mask)
 //    always returned.
 
 template <typename TValue>
-inline bool genTypeValueFitsIn(TValue value, var_types type)
+inline bool genTypeCanRepresentValue(var_types type, TValue value)
 {
     switch (type)
     {
index 7856519..f024a9c 100644 (file)
@@ -2198,23 +2198,24 @@ void Lowering::LowerCompare(GenTree* cmp)
             // below is only necessary to prevent worse code generation for switches and loop cloning.
             //
 
-            GenTree*& longOp    = op1Is64Bit ? cmp->gtOp.gtOp1 : cmp->gtOp.gtOp2;
-            GenTree*& smallerOp = op2Is64Bit ? cmp->gtOp.gtOp1 : cmp->gtOp.gtOp2;
+            GenTree*  longOp       = op1Is64Bit ? cmp->gtOp.gtOp1 : cmp->gtOp.gtOp2;
+            GenTree** smallerOpUse = op2Is64Bit ? &cmp->gtOp.gtOp1 : &cmp->gtOp.gtOp2;
+            var_types smallerType  = (*smallerOpUse)->TypeGet();
 
-            assert(genTypeSize(smallerOp) < 8);
+            assert(genTypeSize(smallerType) < 8);
 
-            if (longOp->IsCnsIntOrI() && genTypeValueFitsIn(longOp->AsIntCon()->IconValue(), smallerOp->TypeGet()))
+            if (longOp->IsCnsIntOrI() && genTypeCanRepresentValue(smallerType, longOp->AsIntCon()->IconValue()))
             {
-                longOp->gtType = smallerOp->TypeGet();
+                longOp->gtType = smallerType;
             }
-            else if (smallerOp->IsCnsIntOrI())
+            else if ((*smallerOpUse)->IsCnsIntOrI())
             {
-                smallerOp->gtType = TYP_LONG;
+                (*smallerOpUse)->gtType = TYP_LONG;
             }
             else
             {
-                GenTree* cast = comp->gtNewCastNode(TYP_LONG, smallerOp, TYP_LONG);
-                smallerOp     = cast;
+                GenTree* cast = comp->gtNewCastNode(TYP_LONG, *smallerOpUse, TYP_LONG);
+                *smallerOpUse = cast;
                 BlockRange().InsertAfter(cast->gtGetOp1(), cast);
             }
         }
@@ -2228,7 +2229,7 @@ void Lowering::LowerCompare(GenTree* cmp)
         GenTreeIntCon* op2      = cmp->gtGetOp2()->AsIntCon();
         ssize_t        op2Value = op2->IconValue();
 
-        if (op1->isMemoryOp() && varTypeIsSmall(op1Type) && genTypeValueFitsIn(op2Value, op1Type))
+        if (op1->isMemoryOp() && varTypeIsSmall(op1Type) && genTypeCanRepresentValue(op1Type, op2Value))
         {
             //
             // If op1's type is small then try to narrow op2 so it has the same type as op1.