diff options
author | Jingyue Wu <jingyue@google.com> | 2014-06-05 22:07:33 +0000 |
---|---|---|
committer | Jingyue Wu <jingyue@google.com> | 2014-06-05 22:07:33 +0000 |
commit | 84465473e7519a6194e5918385ce45a74328b498 (patch) | |
tree | a7dee8104a35816b92a7476444361bb8a607a076 /clang/lib/CodeGen/CodeGenModule.h | |
parent | f438164d3046e17c73d1fb94af34ec59f162bca5 (diff) | |
download | bcm5719-llvm-84465473e7519a6194e5918385ce45a74328b498.tar.gz bcm5719-llvm-84465473e7519a6194e5918385ce45a74328b498.zip |
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.
llvm-svn: 210291
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.h')
0 files changed, 0 insertions, 0 deletions