[PATCH] D51629: [Local] Keep K's range if K does not move when combining metadata.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 4 07:04:37 PDT 2018


fhahn created this revision.
fhahn added reviewers: efriedma, nlopes, davide.
Herald added a subscriber: jfb.

As K has to dominate I, IIUC I's range metadata must be a subset of
K's. After Eli's recent clarification to the LangRef, loading a value
outside of the range is undefined behavior.
Therefore if I's range contains elements outside of K's range and we would load
one such value, K would cause undefined behavior.

In cases like hoisting/sinking, we still want the most generic range
over all code paths to/from the hoist/sink point. As suggested in the
patches related to https://reviews.llvm.org/D47339, I will refactor the handling of those
scenarios and try to decouple it from this function as follow up, once
we switched to a similar handling of metadata in most of
combineMetadata.

I updated some tests checking mostly the merging of metadata to keep the
metadata of to dominating load. The most interesting one is probably test8 in
test/Transforms/JumpThreading/thread-loads.ll. It contained a comment
about the alias metadata preventing us to eliminate the branch, but it
seem like the actual problem currently is that we merge the ranges of
both loads and cannot eliminate the icmp afterwards. With this patch, we
manage to eliminate the icmp, as the range of the first load excludes 8.


https://reviews.llvm.org/D51629

Files:
  lib/Transforms/Utils/Local.cpp
  test/Transforms/GVN/range.ll
  test/Transforms/InstCombine/load-combine-metadata.ll
  test/Transforms/JumpThreading/thread-loads.ll
  test/Transforms/NewGVN/range.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51629.163801.patch
Type: text/x-patch
Size: 8982 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180904/9060a802/attachment.bin>


More information about the llvm-commits mailing list