diff options
author | Daniil Suchkov <suc-daniil@yandex.ru> | 2019-11-14 15:25:31 +0700 |
---|---|---|
committer | Daniil Suchkov <suc-daniil@yandex.ru> | 2019-11-14 17:04:32 +0700 |
commit | a2f6ae9abffcba260c22bb235879f0576bf3b783 (patch) | |
tree | ebece2b3649cab3594802418b9857d748f460346 /llvm/lib/Transforms/InstCombine/InstCombineInternal.h | |
parent | 2eb0862ed8a824f0d02c3df6ec4e05175cf8c3f1 (diff) | |
download | bcm5719-llvm-a2f6ae9abffcba260c22bb235879f0576bf3b783.tar.gz bcm5719-llvm-a2f6ae9abffcba260c22bb235879f0576bf3b783.zip |
[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
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineInternal.h')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineInternal.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h index 524f9313d8c..52aeb787aaf 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h +++ b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h @@ -895,6 +895,11 @@ private: /// insert a new pointer typed PHI and replace the original one. Instruction *FoldIntegerTypedPHI(PHINode &PN); + /// If all incoming values of a pointer typed PHI are pointers with the same + /// base and offset, replace the PHI and all incoming values with one + /// definition of such pointer. + Instruction *FoldPHIWithEqualPointers(PHINode &PN); + /// Helper function for FoldPHIArgXIntoPHI() to set debug location for the /// folded operation. void PHIArgMergedDebugLoc(Instruction *Inst, PHINode &PN); |