Go to file
Chen Li 5cde8389cf [IndVarSimplify] Rewrite loop exit values with their initial values from loop preheader
Summary:
This is a revised version of D13974, and the following quoted summary are from D13974

"This patch adds support to check if a loop has loop invariant conditions which lead to loop exits. If so, we know that if the exit path is taken, it is at the first loop iteration. If there is an induction variable used in that exit path whose value has not been updated, it will keep its initial value passing from loop preheader. We can therefore rewrite the exit value with
its initial value. This will help remove phis created by LCSSA and enable other optimizations like loop unswitch."

D13974 was committed but failed one lnt test. The bug was that we only checked the condition from loop exit's incoming block was a loop invariant. But there could be another condition from loop header to that incoming block not being a loop invariant. This would produce miscompiled code.

This patch fixes the issue by checking if the incoming block is loop header, and if not, don't perform the rewrite. The could be further improved by recursively checking all conditions leading to loop exit block, but I'd like to check in this simple version first and improve it with future patches.     

Reviewers: sanjoy

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D16570

llvm-svn: 258912
2016-01-27 07:40:41 +00:00
clang Fix array index out of bounds 2016-01-27 07:33:50 +00:00
clang-tools-extra Fix Clang-tidy modernize-use-override warning in unittests/clang-tidy/IncludeInserterTest.cpp; other minor fixes. 2016-01-26 22:32:24 +00:00
compiler-rt Sync up with master file 2016-01-27 00:14:15 +00:00
debuginfo-tests New round of fixes for "Always compile debuginfo-tests for the host triple" 2014-10-18 23:47:59 +00:00
libclc AMDGPU: Add aliases for all VI targets 2015-12-15 18:37:04 +00:00
libcxx [libcxx] Remove -Wpadded from buildit script. 2016-01-27 01:55:11 +00:00
libcxxabi [libcxxabi] Teach cxa_demangle about Hexagon's long double size 2016-01-20 14:10:23 +00:00
libunwind Replace cmake check for printf with a check for fopen. 2015-12-10 00:47:08 +00:00
lld Fix Clang-tidy modernize-use-nullptr warnings in include/lld/Core/range.h; other minor fixes. 2016-01-26 18:27:37 +00:00
lldb Revert r258546. 2016-01-26 17:43:48 +00:00
llgo [llgo] Force exporting __morestack from llgoi 2015-11-27 04:46:46 +00:00
llvm [IndVarSimplify] Rewrite loop exit values with their initial values from loop preheader 2016-01-27 07:40:41 +00:00
openmp Change whitespace to test commit access 2016-01-27 07:24:03 +00:00
polly Unique phi write accesses 2016-01-26 13:33:27 +00:00