[all-commits] [llvm/llvm-project] b1b8a3: [InstCombine] Remove one-use restriction on icmp o...

Nikita Popov via All-commits all-commits at lists.llvm.org
Fri Feb 9 06:25:36 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b1b8a383fcdab007ccd1a5daa08cb33ce7cbc6c0
      https://github.com/llvm/llvm-project/commit/b1b8a383fcdab007ccd1a5daa08cb33ce7cbc6c0
  Author: Nikita Popov <npopov at redhat.com>
  Date:   2024-02-09 (Fri, 09 Feb 2024)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
    M llvm/test/Transforms/InstCombine/icmp-custom-dl.ll
    M llvm/test/Transforms/InstCombine/icmp-gep.ll

  Log Message:
  -----------
  [InstCombine] Remove one-use restriction on icmp of gep fold (#76730)

The fold for icmp (gep (p, i1), gep (p, i2)) to icmp (i1, i2) is
currently limited to one of the GEPs either having one use or a constant
offset. I believe this is to avoid duplicating complex arithmetic both
in the GEP and the offset comparison.

This patch instead does the same thing that the indexed compare fold
does, which is to rewrite the GEP into i8 form if necessary, so that the
offset arithmetic is not repeated after the transform.

I ran into this problem in a case where there are multiple conditions on
the same pointer, which prevents them from getting folded.




More information about the All-commits mailing list