llvm-6502/lib/Transforms/Scalar
Jingyue Wu 6156e562ef Fixed several correctness issues in SeparateConstOffsetFromGEP
Most issues are on mishandling s/zext.

Fixes:

1. When rebuilding new indices, s/zext should be distributed to
sub-expressions. e.g., sext(a +nsw (b +nsw 5)) = sext(a) + sext(b) + 5 but not
sext(a + b) + 5. This also affects the logic of recursively looking for a
constant offset, we need to include s/zext into the context of the searching.

2. Function find should return the bitwidth of the constant offset instead of
always sign-extending it to i64.

3. Stop shortcutting zext'ed GEP indices. LLVM conceptually sign-extends GEP
indices to pointer-size before computing the address. Therefore, gep base,
zext(a + b) != gep base, a + b

Improvements:

1. Add an optimization for splitting sext(a + b): if a + b is proven
non-negative (e.g., used as an index of an inbound GEP) and one of a, b is
non-negative, sext(a + b) = sext(a) + sext(b)

2. Function Distributable checks whether both sext and zext can be distributed
to operands of a binary operator. This helps us split zext(sext(a + b)) to
zext(sext(a) + zext(sext(b)) when a + b does not signed or unsigned overflow.

Refactoring:

Merge some common logic of handling add/sub/or in find.

Testing:

Add many tests in split-gep.ll and split-gep-and-gvn.ll to verify the changes
we made.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210291 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-05 22:07:33 +00:00
..
ADCE.cpp
CMakeLists.txt Add LoadCombine pass. 2014-05-29 01:55:07 +00:00
ConstantHoisting.cpp ConstantHoisting.cpp: Add <tuple> for std::tie, since r207593 removed FileSystem.h, it includes <tuple>. 2014-04-30 06:44:50 +00:00
ConstantProp.cpp
CorrelatedValuePropagation.cpp
DCE.cpp
DeadStoreElimination.cpp
EarlyCSE.cpp
FlattenCFGPass.cpp
GlobalMerge.cpp Revert "Implement global merge optimization for global variables." 2014-05-16 13:02:18 +00:00
GVN.cpp GVN: Fix non-determinism in map iteration. 2014-05-13 21:06:40 +00:00
IndVarSimplify.cpp
JumpThreading.cpp
LICM.cpp
LLVMBuild.txt
LoadCombine.cpp Add LoadCombine pass. 2014-05-29 01:55:07 +00:00
LoopDeletion.cpp
LoopIdiomRecognize.cpp Tidy up. 2014-04-29 22:41:58 +00:00
LoopInstSimplify.cpp
LoopRerollPass.cpp
LoopRotation.cpp Make the LoopRotate pass's maximum header size configurable both programmatically 2014-05-26 08:58:51 +00:00
LoopStrengthReduce.cpp [LSR] Canonicalize reg1 + ... + regN into reg1 + ... + 1*regN. 2014-05-20 19:25:04 +00:00
LoopUnrollPass.cpp LoopUnroll: If we're doing partial unrolling, use the PartialThreshold to limit unrolling. 2014-05-04 19:12:38 +00:00
LoopUnswitch.cpp
LowerAtomic.cpp
Makefile
MemCpyOptimizer.cpp
PartiallyInlineLibCalls.cpp
Reassociate.cpp [Reassociate] Similar to "X + -X" -> "0", added code to handle "X + ~X" -> "-1". 2014-05-31 15:01:54 +00:00
Reg2Mem.cpp
SampleProfile.cpp
Scalar.cpp Add LoadCombine pass. 2014-05-29 01:55:07 +00:00
Scalarizer.cpp
ScalarReplAggregates.cpp
SCCP.cpp
SeparateConstOffsetFromGEP.cpp Fixed several correctness issues in SeparateConstOffsetFromGEP 2014-06-05 22:07:33 +00:00
SimplifyCFGPass.cpp
Sink.cpp
SROA.cpp
StructurizeCFG.cpp Use range for 2014-05-19 17:52:48 +00:00
TailRecursionElimination.cpp Add support for missed and analysis optimization remarks. 2014-05-22 14:19:46 +00:00