@@ -80,6 +80,10 @@ GenTree* LC_Array::ToGenTree(Compiler* comp, BasicBlock* bb)
80
80
arrAddr->gtFlags |= GTF_INX_ADDR_NONNULL;
81
81
82
82
arr = comp->gtNewIndexIndir (arrAddr->AsIndexAddr ());
83
+
84
+ // We don't really need to call morph here if we import arr[i] directly
85
+ // without gtNewArrayIndexAddr (but it's a bit of verbose).
86
+ arr = comp->fgMorphTree (arr);
83
87
}
84
88
// If asked for arrlen invoke arr length operator.
85
89
if (oper == ArrLen)
@@ -861,98 +865,41 @@ BasicBlock* LoopCloneContext::CondToStmtInBlock(Compiler*
861
865
//
862
866
const weight_t fastLikelihood = fastPathWeightScaleFactor;
863
867
864
- // Choose how to generate the conditions
865
- const bool generateOneConditionPerBlock = true ;
866
-
867
- if (generateOneConditionPerBlock)
868
- {
869
- // N = conds.Size() branches must all be true to execute the fast loop.
870
- // Use the N'th root....
871
- //
872
- const weight_t fastLikelihoodPerBlock = exp (log (fastLikelihood) / (weight_t )conds.Size ());
873
-
874
- for (unsigned i = 0 ; i < conds.Size (); ++i)
875
- {
876
- BasicBlock* newBlk = comp->fgNewBBafter (BBJ_COND, insertAfter, /* extendRegion*/ true );
877
- newBlk->inheritWeight (insertAfter);
878
-
879
- JITDUMP (" Adding " FMT_BB " -> " FMT_BB " \n " , newBlk->bbNum , slowPreheader->bbNum );
880
- FlowEdge* const trueEdge = comp->fgAddRefPred (slowPreheader, newBlk);
881
- newBlk->SetTrueEdge (trueEdge);
882
- trueEdge->setLikelihood (1 - fastLikelihoodPerBlock);
883
-
884
- if (insertAfter->KindIs (BBJ_COND))
885
- {
886
- JITDUMP (" Adding " FMT_BB " -> " FMT_BB " \n " , insertAfter->bbNum , newBlk->bbNum );
887
- FlowEdge* const falseEdge = comp->fgAddRefPred (newBlk, insertAfter);
888
- insertAfter->SetFalseEdge (falseEdge);
889
- falseEdge->setLikelihood (fastLikelihoodPerBlock);
890
- }
891
-
892
- JITDUMP (" Adding conditions %u to " FMT_BB " \n " , i, newBlk->bbNum );
893
-
894
- GenTree* cond = conds[i].ToGenTree (comp, newBlk, /* invert */ true );
895
- GenTree* jmpTrueTree = comp->gtNewOperNode (GT_JTRUE, TYP_VOID, cond);
896
- Statement* stmt = comp->fgNewStmtFromTree (jmpTrueTree);
897
-
898
- comp->fgInsertStmtAtEnd (newBlk, stmt);
899
-
900
- // Remorph.
901
- JITDUMP (" Loop cloning condition tree before morphing:\n " );
902
- DBEXEC (comp->verbose , comp->gtDispTree (jmpTrueTree));
903
- JITDUMP (" \n " );
904
- comp->fgMorphBlockStmt (newBlk, stmt DEBUGARG (" Loop cloning condition" ));
905
-
906
- insertAfter = newBlk;
907
- }
868
+ // N = conds.Size() branches must all be true to execute the fast loop.
869
+ // Use the N'th root....
870
+ //
871
+ const weight_t fastLikelihoodPerBlock = exp (log (fastLikelihood) / (weight_t )conds.Size ());
908
872
909
- return insertAfter;
910
- }
911
- else
873
+ for (unsigned i = 0 ; i < conds.Size (); ++i)
912
874
{
913
875
BasicBlock* newBlk = comp->fgNewBBafter (BBJ_COND, insertAfter, /* extendRegion*/ true );
914
876
newBlk->inheritWeight (insertAfter);
915
877
916
878
JITDUMP (" Adding " FMT_BB " -> " FMT_BB " \n " , newBlk->bbNum , slowPreheader->bbNum );
917
879
FlowEdge* const trueEdge = comp->fgAddRefPred (slowPreheader, newBlk);
918
880
newBlk->SetTrueEdge (trueEdge);
919
- trueEdge->setLikelihood (1.0 - fastLikelihood );
881
+ trueEdge->setLikelihood (1 - fastLikelihoodPerBlock );
920
882
921
883
if (insertAfter->KindIs (BBJ_COND))
922
884
{
923
885
JITDUMP (" Adding " FMT_BB " -> " FMT_BB " \n " , insertAfter->bbNum , newBlk->bbNum );
924
886
FlowEdge* const falseEdge = comp->fgAddRefPred (newBlk, insertAfter);
925
887
insertAfter->SetFalseEdge (falseEdge);
926
- falseEdge->setLikelihood (fastLikelihood);
927
- }
928
-
929
- JITDUMP (" Adding conditions to " FMT_BB " \n " , newBlk->bbNum );
930
-
931
- // Get the first condition.
932
- GenTree* cond = conds[0 ].ToGenTree (comp, newBlk, /* invert */ false );
933
- for (unsigned i = 1 ; i < conds.Size (); ++i)
934
- {
935
- // Append all conditions using AND operator.
936
- cond = comp->gtNewOperNode (GT_AND, TYP_INT, cond, conds[i].ToGenTree (comp, newBlk, /* invert */ false ));
888
+ falseEdge->setLikelihood (fastLikelihoodPerBlock);
937
889
}
938
890
939
- // Add "cond == 0" node
940
- cond = comp->gtNewOperNode (GT_EQ, TYP_INT, cond, comp->gtNewIconNode (0 ));
891
+ JITDUMP (" Adding conditions %u to " FMT_BB " \n " , i, newBlk->bbNum );
941
892
942
- // Add jmpTrue "cond == 0"
893
+ GenTree* cond = conds[i].ToGenTree (comp, newBlk, /* invert */ true );
894
+ cond->gtFlags |= (GTF_RELOP_JMP_USED | GTF_DONT_CSE);
943
895
GenTree* jmpTrueTree = comp->gtNewOperNode (GT_JTRUE, TYP_VOID, cond);
944
896
Statement* stmt = comp->fgNewStmtFromTree (jmpTrueTree);
945
897
946
898
comp->fgInsertStmtAtEnd (newBlk, stmt);
947
-
948
- // Remorph.
949
- JITDUMP (" Loop cloning condition tree before morphing:\n " );
950
- DBEXEC (comp->verbose , comp->gtDispTree (jmpTrueTree));
951
- JITDUMP (" \n " );
952
- comp->fgMorphBlockStmt (newBlk, stmt DEBUGARG (" Loop cloning condition" ));
953
-
954
- return newBlk;
899
+ insertAfter = newBlk;
955
900
}
901
+
902
+ return insertAfter;
956
903
}
957
904
958
905
// --------------------------------------------------------------------------------------------------
0 commit comments