[InstCombine] Fold PHIs with equal incoming pointers
authorDaniil Suchkov <suc-daniil@yandex.ru>
Thu, 14 Nov 2019 08:25:31 +0000 (15:25 +0700)
committerDaniil Suchkov <suc-daniil@yandex.ru>
Thu, 14 Nov 2019 10:04:32 +0000 (17:04 +0700)
commita2f6ae9abffcba260c22bb235879f0576bf3b783
treeebece2b3649cab3594802418b9857d748f460346
parent2eb0862ed8a824f0d02c3df6ec4e05175cf8c3f1
[InstCombine] Fold PHIs with equal incoming pointers

This is a resubmission of bbb29738b58aaf6f6518269abdcf8f64131665a9 that
was reverted due to clang tests failures. It includes the fix and
additional IR tests for the missed case.

Summary:
In case when all incoming values of a PHI are equal pointers, this
transformation inserts a definition of such a pointer right after
definition of the base pointer and replaces with this value both PHI and
all it's incoming pointers. Primary goal of this transformation is
canonicalization of this pattern in order to enable optimizations that
can't handle PHIs. Non-inbounds pointers aren't currently supported.

Reviewers: spatel, RKSimon, lebedev.ri, apilipenko

Reviewed By: apilipenko

Tags: #llvm

Subscribers: hiraditya, llvm-commits

Differential Revision: https://reviews.llvm.org/D68128
llvm/lib/Transforms/InstCombine/InstCombineInternal.h
llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp
llvm/test/Transforms/InstCombine/phi-equal-incoming-pointers.ll