[all-commits] [llvm/llvm-project] c117d7: [ConstantFold] Refactor load folding

Nikita Popov via All-commits all-commits at lists.llvm.org
Tue Oct 5 09:08:19 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c117d77e937f410a2b9c54eaec0fc5fe2a653399
      https://github.com/llvm/llvm-project/commit/c117d77e937f410a2b9c54eaec0fc5fe2a653399
  Author: Nikita Popov <nikita.ppv at gmail.com>
  Date:   2021-10-05 (Tue, 05 Oct 2021)

  Changed paths:
    M llvm/lib/Analysis/ConstantFolding.cpp
    M llvm/test/Transforms/InstSimplify/ConstProp/loads.ll
    M llvm/test/Transforms/InstSimplify/load.ll

  Log Message:
  -----------
  [ConstantFold] Refactor load folding

This refactors load folding to happen in two cleanly separated
steps: ConstantFoldLoadFromConstPtr() takes a pointer to load from
and decomposes it into a constant initializer base and an offset.
Then ConstantFoldLoadFromConst() loads from that initializer at
the given offset. This makes the core logic independent of having
actual GEP expressions (and those GEP expressions having certain
structure) and will allow exposing ConstantFoldLoadFromConst() as
an independent API in the future.

This is mostly only a refactoring, but it does make the folding
logic slightly more powerful.

Differential Revision: https://reviews.llvm.org/D111023




More information about the All-commits mailing list