[all-commits] [llvm/llvm-project] 75c7e3: [NFC][InstCombine] Add plain GEP test for (gep i8...

Roman Lebedev via All-commits all-commits at lists.llvm.org
Sat Mar 6 12:00:57 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 75c7e3e3145f06d85b9580d4a1c9bc7f4b5a9a9e
      https://github.com/llvm/llvm-project/commit/75c7e3e3145f06d85b9580d4a1c9bc7f4b5a9a9e
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2021-03-06 (Sat, 06 Mar 2021)

  Changed paths:
    M llvm/test/Transforms/InstCombine/getelementptr.ll

  Log Message:
  -----------
  [NFC][InstCombine] Add plain GEP test for  (gep i8* X, -(ptrtoint Y))  -->  (inttoptr (sub (ptrtoint X), (ptrtoint Y)))  fold


  Commit: 2ad1f5eb1a47275593bd9baf75dcf3e9c3977473
      https://github.com/llvm/llvm-project/commit/2ad1f5eb1a47275593bd9baf75dcf3e9c3977473
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2021-03-06 (Sat, 06 Mar 2021)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
    M llvm/test/Transforms/InstCombine/getelementptr.ll

  Log Message:
  -----------
  [InstCombine] Don't canonicalize  (gep i8* X, -(ptrtoint Y))  as  (inttoptr (sub (ptrtoint X), (ptrtoint Y)))

It's just a wrong thing to do.

We introduce inttoptr where there were none, which results in
loosing all provenance information because we no longer have a GEP{i,},
and pessimize all future optimizations,
because we are basically not allowed to look past `inttoptr`.

(gep i8* X, -(ptrtoint Y))  *is* the canonical form.
So just drop this fold.

Noticed while reviewing D98120.


Compare: https://github.com/llvm/llvm-project/compare/9fb6782c6945...2ad1f5eb1a47


More information about the All-commits mailing list