[all-commits] [llvm/llvm-project] 915c3b: [InstCombine] Fold variable extract of a constant-...

Domenic Nutile via All-commits all-commits at lists.llvm.org
Thu Sep 24 11:05:04 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 915c3bd9d4659165e1b4bb4a13204d559592b1c0
      https://github.com/llvm/llvm-project/commit/915c3bd9d4659165e1b4bb4a13204d559592b1c0
  Author: Domenic Nutile <domenic.nutile at gmail.com>
  Date:   2026-09-24 (Thu, 24 Sep 2026)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
    A llvm/test/Transforms/InstCombine/extractelement-strided-ptr-vector.ll

  Log Message:
  -----------
  [InstCombine] Fold variable extract of a constant-strided pointer vector (#217078)

A vector built from pointers that all point into the same object at a
constant stride is a table of addresses, so a variable extract from it
is address arithmetic:

  %v0 = insertelement <4 x ptr> poison, ptr %b,      i64 0
  %v1 = insertelement <4 x ptr> %v0,    ptr %b + 8,  i64 1
  %v2 = insertelement <4 x ptr> %v1,    ptr %b + 16, i64 2
  %v3 = insertelement <4 x ptr> %v2,    ptr %b + 24, i64 3
  %r  = extractelement <4 x ptr> %v3, i32 %i
  -->
  %r  = getelementptr i8, ptr %b, i64 %i * 8

Fold it to a single GEP. Every element must be reachable from one base
pointer at a constant byte offset, every lane of the vector must be
defined, and the offsets must form an arithmetic sequence; otherwise the
pattern is left alone.



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