[all-commits] [llvm/llvm-project] 29555a: [InstCombine] Improve inbounds preservation for AD...

Björn Pettersson via All-commits all-commits at lists.llvm.org
Mon Apr 14 02:03:28 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 29555ad5efea20308c7a5ee851a4cba9093a607d
      https://github.com/llvm/llvm-project/commit/29555ad5efea20308c7a5ee851a4cba9093a607d
  Author: Björn 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 inbounds preservation for ADD+GEP -> GEP+GEP (#135155)

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", and "nusw nuw" instead of "inbounds nuw"
on the getelementptr.

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



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