[all-commits] [llvm/llvm-project] d01237: [InstCombine] Make indexed compare fold GEP source...

Nikita Popov via All-commits all-commits at lists.llvm.org
Tue Nov 28 00:16:21 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d01237c45b7cdbf83d1249dd019178b2cafbb63c
      https://github.com/llvm/llvm-project/commit/d01237c45b7cdbf83d1249dd019178b2cafbb63c
  Author: Nikita Popov <npopov at redhat.com>
  Date:   2023-11-28 (Tue, 28 Nov 2023)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
    M llvm/test/Transforms/InstCombine/indexed-gep-compares.ll
    M llvm/test/Transforms/InstCombine/opaque-ptr.ll

  Log Message:
  -----------
  [InstCombine] Make indexed compare fold GEP source type independent (#71663)

The indexed compare fold converts comparisons of GEPs with same
(indirect) base into comparisons of offset. Currently, it only supports
GEPs with the same source element type.

This change makes the transform operate on offsets instead, which
removes the type dependence. To keep closer to the scope of the original
implementation, this keeps the limitation that we should only have at
most one variable index per GEP.

This addresses the main regression from
https://github.com/llvm/llvm-project/pull/68882.

TBH I have some doubts that this is really a useful transform (at least
for the case where there are extra pointer users, so we have to
rematerialize pointers at some point). I can only assume it exists for a
reason...




More information about the All-commits mailing list