[all-commits] [llvm/llvm-project] 2717f6: [GlobalISel] Make G_PTR_ADD pattern matcher non-co...

Daniel Thornburgh via All-commits all-commits at lists.llvm.org
Thu Dec 9 12:38:30 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2717f62c97cf134b4ef7bd5b03e046ebf3f5efc2
      https://github.com/llvm/llvm-project/commit/2717f62c97cf134b4ef7bd5b03e046ebf3f5efc2
  Author: Daniel Thornburgh <mysterymath at gmail.com>
  Date:   2021-12-09 (Thu, 09 Dec 2021)

  Changed paths:
    M llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h
    M llvm/test/CodeGen/AArch64/GlobalISel/combine-ptradd-reassociation.mir

  Log Message:
  -----------
  [GlobalISel] Make G_PTR_ADD pattern matcher non-commutative.

G_PTR_ADD takes arguments of two different types, so it probably shouldn't be
considered commutative just on that basis. A recent G_PTR_ADD reassociation
optimization (https://reviews.llvm.org/D109528) can emit erroneous code if the
pattern matcher commutes the arguments; this can happen when the base pointer
was created by G_INTTOPTR of a G_CONSTANT and the offset register is variable.

This was discovered on the llvm-mos fork, but I added a failing test case that
should apply to AArch64 (and more generally).

Differential Revision: https://reviews.llvm.org/D114655




More information about the All-commits mailing list