Open
Description
Loops with byte
/short
iteration variables:
for (byte i = 0; i < 100; i++)
{
a[i] = 0;
}
create an iteration increment tree with a CAST node:
***** BB03
STMT00003 ( 0x00E[E-] ... 0x012 )
[000025] -A---+----- * ASG int
[000024] D----+-N--- +--* LCL_VAR int V01 loc0
[000023] -----+----- \--* CAST int <- ubyte <- int
[000022] -----+----- \--* ADD int
[000020] -----+----- +--* LCL_VAR int V01 loc0
[000021] -----+----- \--* CNS_INT int 1
This pattern is not matched by GenTree::IsLclVarUpdateTree()
.
Loops with long
iteration variables:
for (long i = 0; i < 100; i++)
{
a[i] = 0;
}
create (naturally) an increment constant that is long
typed:
STMT00003 ( 0x00B[E-] ... 0x00F )
[000022] -A---+----- * ASG long
[000021] D----+-N--- +--* LCL_VAR long V01 loc0
[000020] -----+----- \--* ADD long
[000017] -----+----- +--* LCL_VAR long V01 loc0
[000019] -----+----- \--* CNS_INT long 1
and that is screened out by Compiler::optIsLoopIncrTree()
:
if ((incrVal->gtOper != GT_CNS_INT) || (incrVal->TypeGet() != TYP_INT))
category:cq
theme:loop-opt
skill-level:expert
cost:small
impact:small