[PATCH] [InstCombine] Properly combine metadata when replacing a load with another

Hal Finkel hfinkel at anl.gov
Mon Jun 22 18:16:57 PDT 2015

Hi Björn,

+      unsigned KnownIDs[] = {

+        LLVMContext::MD_range,

+        LLVMContext::MD_invariant_load,

+        LLVMContext::MD_nonnull,

+      };

+      combineMetadata(NLI, &LI, KnownIDs);

Dropping all AA metadata on these loads when we combine them seems quite unfortunate; we should at least be able to keep the AA metadata from the original load. FindAvailableLoadedValue will return the the AATags as an optional output parameter. You could then call setAAMetadata after you run the combining. Please add a test case for this.

Also, while you're here, as follow-up, it seems like we should be able to pass the AA parameter to FindAvailableLoadedValue too. Should be easy to come up with a test: just stick a store to some noalias pointer in between the two loads.

Thanks again,

----- Original Message -----
> From: "Björn Steinbrink" <bsteinbr at gmail.com>
> To: llvm-commits at cs.uiuc.edu
> Sent: Monday, June 22, 2015 7:56:56 AM
> Subject: [PATCH] [InstCombine] Properly combine metadata when replacing a	load with another
> Not doing this can lead to misoptimizations down the line, e.g.
> because
> of range metadata on the replacing load excluding values that are
> valid
> for the load that is being replaced.
> ---
>  .../InstCombine/InstCombineLoadStoreAlloca.cpp        | 12
>  +++++++++++-
>  test/Transforms/InstCombine/load-range-metadata.ll    | 19
>  +++++++++++++++++++
>  2 files changed, 30 insertions(+), 1 deletion(-)
>  create mode 100644
>  test/Transforms/InstCombine/load-range-metadata.ll
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory

More information about the llvm-commits mailing list