llvm-6502/lib
Pete Cooper 71a4b301fd Loop idiom recognizer was replacing too many uses of popcount.
When spotting that a loop can use ctpop, we were incorrectly replacing all uses of a value with a value derived from ctpop.

The bug here was exposed because we were replacing a use prior to the ctpop with the ctpop value and so we have a use before def, i.e., we changed

 %tobool.5 = icmp ne i32 %num, 0
 store i1 %tobool.5, i1* %ptr
 br i1 %tobool.5, label %for.body.lr.ph, label %for.end

to

 store i1 %1, i1* %ptr
 %0 = call i32 @llvm.ctpop.i32(i32 %num)
 %1 = icmp ne i32 %0, 0
 br i1 %1, label %for.body.lr.ph, label %for.end

Even if we inserted the ctpop so that it dominates the store here, that would still be incorrect.  The store doesn’t want the result of ctpop.

The fix is very simple, and involves replacing only the branch condition with the ctpop instead of all uses.

Reviewed by Hal Finkel.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242068 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-13 21:25:33 +00:00
..
Analysis Cleanup after r241809 - remove uncessary call to std::sort 2015-07-13 14:48:24 +00:00
AsmParser Add argmemonly attribute. 2015-07-11 10:30:36 +00:00
Bitcode Add argmemonly attribute. 2015-07-11 10:30:36 +00:00
CodeGen [WinEH] Emit the LSDA even if no lpads remain but outlining occurred 2015-07-13 20:41:46 +00:00
DebugInfo
ExecutionEngine
Fuzzer
IR Remove macro guards for extern template instantiations. 2015-07-13 17:21:31 +00:00
IRReader
LibDriver Add support deterministic output in llvm-ar and make it the default. 2015-07-13 20:38:09 +00:00
LineEditor
Linker
LTO
MC [MC] Correctly escape .safeseh's symbol 2015-07-13 18:51:15 +00:00
Object Add support deterministic output in llvm-ar and make it the default. 2015-07-13 20:38:09 +00:00
Option
Passes
ProfileData
Support Remove macro guards for extern template instantiations. 2015-07-13 17:21:31 +00:00
TableGen
Target [Hexagon] Move BitTracker into the llvm namespace and remove redundant qualifications 2015-07-13 20:38:16 +00:00
Transforms Loop idiom recognizer was replacing too many uses of popcount. 2015-07-13 21:25:33 +00:00
CMakeLists.txt
LLVMBuild.txt
Makefile