[InstCombine] Fix PR35618: Instcombine hangs on single minmax load bitcast.
authorAlexey Bataev <a.bataev@hotmail.com>
Tue, 12 Dec 2017 20:28:46 +0000 (20:28 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Tue, 12 Dec 2017 20:28:46 +0000 (20:28 +0000)
commit83c15b136337ea3f23917e4294d12a695ff7c788
treecdb03e2d6a15b13cc9cd8e240f5fb4cbd968534d
parent212bcf8370d43dcbaa4a787cca84259ec140546e
[InstCombine] Fix PR35618: Instcombine hangs on single minmax load bitcast.

Summary:
If we have pattern `store (load(bitcast(select (cmp(V1, V2), &V1,
&V2)))), bitcast)`, but the load is used in other instructions, it leads
to looping in InstCombiner. Patch adds additional check that all users
of the load instructions are stores and then replaces all uses of load
instruction by the new one with new type.

Reviewers: RKSimon, spatel, majnemer

Subscribers: llvm-commits

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

llvm-svn: 320525
llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
llvm/test/Transforms/InstCombine/multiple-uses-load-bitcast-select.ll [new file with mode: 0644]