Skip to content

Commit

Permalink
Simplify KeysetIterEnd and BespokeIterEnd on static arrays to Count
Browse files Browse the repository at this point in the history
Summary:
Static arrays do not have tombstones. Without tombstones, IterEnd is the same
as Count, so simplify them to Count, which we likely already loaded for other
reasons.

This optimizes away tombstone detection, as it will turn IterEnd vs Count
comparison to Count vs Count, where GVN will deduplicate these counts and
simplifier will then optimize away of EqInt on two same SSATmps.

Differential Revision: D57466215

fbshipit-source-id: 9398eb797697691640295aa92ae5f64dcc042038
  • Loading branch information
jano authored and facebook-github-bot committed May 17, 2024
1 parent 1fd797d commit da6a691
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions hphp/runtime/vm/jit/simplify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3247,6 +3247,9 @@ SSATmp* simplifyKeysetIterEnd(State& env, const IRInstruction* inst) {
return cns(env, keyset->iterLimit());
}

// Static keysets do not have tombstones.
if (arr->isA(TStaticKeyset)) return gen(env, CountKeyset, arr);

return nullptr;
}

Expand Down Expand Up @@ -3403,6 +3406,9 @@ SSATmp* simplifyBespokeIterEnd(State& env, const IRInstruction* inst) {
return gen(env, CountDict, arr);
}

// Static arrays do not have tombstones.
if (arr->isA(TStaticArrLike)) return gen(env, Count, arr);

return nullptr;
}

Expand Down

0 comments on commit da6a691

Please sign in to comment.