[PATCH] D62644: [EarlyCSE] Ensure equal keys have the same hash value
Joseph Tremoulet via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 29 21:39:21 PDT 2019
JosephTremoulet created this revision.
JosephTremoulet added reviewers: spatel, nikic.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
The logic in EarlyCSE that looks through 'not' operations in the
predicate recognizes e.g. that `select (not (cmp sgt X, Y)), X, Y` is
equivalent to `select (cmp sgt X, Y), Y, X`. Without this change,
however, only the latter is recognized as a form of `smin X, Y`, so the
two expressions receive different hash codes. This leads to missed
optimization opportunities when the quadratic probing for the two hashes
doesn't happen to collide, and assertion failures when probing doesn't
collide on insertion but does collide on a subsequent table grow
This change inverts the order of some of the pattern matching, checking
first for the optional `not` and then for the min/max/abs patterns, so
that e.g. both expressions above are recognized as a form of `smin X, Y`.
It also adds an assertion to isEqual verifying that it implies equal
hash codes; this fires when there's a collision during insertion, not
just grow, and so will make it easier to notice if these functions fall
out of sync again.
rG LLVM Github Monorepo
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 47838 bytes
Desc: not available
More information about the llvm-commits