[all-commits] [llvm/llvm-project] da92e8: [InstCombine] Fold IntToPtr/PtrToInt to bitcast

Krishnakariya via All-commits all-commits at lists.llvm.org
Sun Jul 18 14:14:53 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: da92e86263c3dcbe0d19fe68d1be2373b74eedf5
      https://github.com/llvm/llvm-project/commit/da92e86263c3dcbe0d19fe68d1be2373b74eedf5
  Author: Krishna Kariya <krishna17060 at iiitd.ac.in>
  Date:   2021-07-18 (Sun, 18 Jul 2021)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
    M llvm/lib/Transforms/InstCombine/InstCombineInternal.h
    M llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
    M llvm/test/Transforms/InstCombine/ptr-int-ptr-icmp.ll

  Log Message:
  -----------
  [InstCombine] Fold IntToPtr/PtrToInt to bitcast

The inttoptr/ptrtoint roundtrip optimization is not always correct.
We are working towards removing this optimization and adding support
to specific cases where this optimization works. This patch is the
first one on this line.

Consider the example:

    %i = ptrtoint i8* %X to i64
    %p = inttoptr i64 %i to i16*
    %cmp = icmp eq i8* %load, %p

In this specific case, the inttoptr/ptrtoint optimization is correct
as it only compares the pointer values. In this patch, we fold
inttoptr/ptrtoint to a bitcast (if src and dest types are different).

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




More information about the All-commits mailing list