[all-commits] [llvm/llvm-project] cbe176: [InstCombine] Allow multi-use OptimizePointerDiffe...

Nikita Popov via All-commits all-commits at lists.llvm.org
Thu Apr 25 18:53:25 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: cbe1760f02882328c91e5764648f97fe644f44c9
      https://github.com/llvm/llvm-project/commit/cbe1760f02882328c91e5764648f97fe644f44c9
  Author: Nikita Popov <npopov at redhat.com>
  Date:   2024-04-26 (Fri, 26 Apr 2024)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
    M llvm/test/Transforms/InstCombine/sub.ll

  Log Message:
  -----------
  [InstCombine] Allow multi-use OptimizePointerDifference() with two GEPs (#90017)

Currently, the OptimizePointerDifference fold does not trigger when
working on the sub of two geps where one of the geps has multiple uses,
to avoid duplicating the offset arithmetic too much.

However, there are cases where performing it would still be
clearly profitable, e.g. test_sub_ptradd_multiuse.

This patch drops the one-use restriction using the same strategy we use
in GEP comparison folds: If there are multiple uses, we rewrite the GEP
to use the expanded offset arithmetic instead (effectively
canonicalizing it into ptradd representation).

Fixes https://github.com/llvm/llvm-project/issues/88231.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list