OSDN Git Service

[SLP]Fix PR39774: Set ReductionRoot if the original instruction is vectorized.
authorAlexey Bataev <a.bataev@hotmail.com>
Wed, 28 Nov 2018 14:34:11 +0000 (14:34 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Wed, 28 Nov 2018 14:34:11 +0000 (14:34 +0000)
commiteb20676bc6787f82818cc86010c89186dba76c0e
tree514ffe0cd0056df31a460a0a898fadba195425e7
parent9d5ac66dc1ff01dee56354344c9da0879f1bdc36
[SLP]Fix PR39774: Set ReductionRoot if the original instruction is vectorized.

Summary:
If the original reduction root instruction was vectorized, it might be
removed from the tree. It means that the insertion point may become
invalidated and the whole vectorization of the reduction leads to the
incorrect output result.
The ReductionRoot instruction must be marked as externally used so it
could not be removed. Otherwise it might cause inconsistency with the
cost model and we may end up with too optimistic optimization.

Reviewers: RKSimon, spatel, hfinkel, mkuper

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@347759 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Vectorize/SLPVectorizer.cpp
test/Transforms/SLPVectorizer/X86/PR39774.ll [new file with mode: 0644]