[all-commits] [llvm/llvm-project] 6decf0: [InstCombine] Improve no-wrap flag preservation fo...

Björn Pettersson via All-commits all-commits at lists.llvm.org
Mon Apr 14 01:32:13 PDT 2025


  Branch: refs/heads/users/bjope/addlikegep_2
  Home:   https://github.com/llvm/llvm-project
  Commit: 6decf0ff33a065d7a46d7818e0272df3b086b008
      https://github.com/llvm/llvm-project/commit/6decf0ff33a065d7a46d7818e0272df3b086b008
  Author: Bjorn Pettersson <bjorn.a.pettersson at ericsson.com>
  Date:   2025-04-14 (Mon, 14 Apr 2025)

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

  Log Message:
  -----------
  [InstCombine] Improve no-wrap flag preservation for ADD+GEP -> GEP+GEP

Given that we have a "add nuw" and a "getelementptr inbounds nuw" like
this:
   %idx = add nuw i64 %idx1, %idx2
   %gep = getelementptr inbounds nuw i32, ptr %ptr, i64 %idx

Then we can preserve the "inbounds nuw" flag when transforming that
into two getelementptr instructions:
   %gep1 = getelementptr inbounds nuw i32, ptr %ptr, i64 %idx1
   %gep = getelementptr inbounds nuw i32, ptr %ptr, i64 %idx2

Similarly for just having "nuw" or "nusw nuw" instead of "inbounds nuw"
on the getelementptr.

Proof: https://alive2.llvm.org/ce/z/QSweWW


  Commit: b0ee9750327de75ae07119940292922e2d7be5d4
      https://github.com/llvm/llvm-project/commit/b0ee9750327de75ae07119940292922e2d7be5d4
  Author: Bjorn Pettersson <bjorn.a.pettersson at ericsson.com>
  Date:   2025-04-14 (Mon, 14 Apr 2025)

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

  Log Message:
  -----------
  Fixups after review feedback:

- Make sure we try to derive inbound + nuw before doing the
  ADD+GEP->GEP+GEP rewrites. This to make it possible to rely
  on "nuw" being present when trying to preserve flags.

- Make sure the special ADDNSW+SEXTLIKE+GEP->GEP+GEP case is checking
  for ADDNUW+ZEXTNNEG+GEP->GEP+GEP when preserving flags.
  This way we do not need to check for non-negative operands.


  Commit: 7d7f3b92408354cb786e28074ca7842f5083bbfc
      https://github.com/llvm/llvm-project/commit/7d7f3b92408354cb786e28074ca7842f5083bbfc
  Author: Bjorn Pettersson <bjorn.a.pettersson at ericsson.com>
  Date:   2025-04-14 (Mon, 14 Apr 2025)

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

  Log Message:
  -----------
  Fix clang-format


  Commit: 205a631fb3fe2acfab0e35e7dc3c48205b0a0e54
      https://github.com/llvm/llvm-project/commit/205a631fb3fe2acfab0e35e7dc3c48205b0a0e54
  Author: Bjorn Pettersson <bjorn.a.pettersson at ericsson.com>
  Date:   2025-04-14 (Mon, 14 Apr 2025)

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

  Log Message:
  -----------
  Fixup


  Commit: 5a14ee7f8a55a8f482bbbcfbe74f0dc2d56a1ff1
      https://github.com/llvm/llvm-project/commit/5a14ee7f8a55a8f482bbbcfbe74f0dc2d56a1ff1
  Author: Bjorn Pettersson <bjorn.a.pettersson at ericsson.com>
  Date:   2025-04-14 (Mon, 14 Apr 2025)

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

  Log Message:
  -----------
  Fixup: Also handle "nusw nuw"


  Commit: a58d4daf86dbf26890cf073b0979512d6768f125
      https://github.com/llvm/llvm-project/commit/a58d4daf86dbf26890cf073b0979512d6768f125
  Author: Bjorn Pettersson <bjorn.a.pettersson at ericsson.com>
  Date:   2025-04-14 (Mon, 14 Apr 2025)

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

  Log Message:
  -----------
  Fixup code comments


  Commit: dd8cdafdc7bf0ffc3b7b1a2778634fd95095f373
      https://github.com/llvm/llvm-project/commit/dd8cdafdc7bf0ffc3b7b1a2778634fd95095f373
  Author: Bjorn Pettersson <bjorn.a.pettersson at ericsson.com>
  Date:   2025-04-14 (Mon, 14 Apr 2025)

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

  Log Message:
  -----------
  Fixup formatting


Compare: https://github.com/llvm/llvm-project/compare/eb5fbb884d2d...dd8cdafdc7bf

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