summaryrefslogtreecommitdiff
path: root/lib/Bitcode/Reader/BitcodeReader.h
diff options
context:
space:
mode:
authorJingyue Wu <jingyue@google.com>2014-06-05 22:07:33 +0000
committerJingyue Wu <jingyue@google.com>2014-06-05 22:07:33 +0000
commit6156e562ef42ed25274c2894aedb22b909184771 (patch)
tree037b8a91c77a8647d7a5d67d824397e58fadfe7c /lib/Bitcode/Reader/BitcodeReader.h
parentd334d25a10f45fc996ba117f8c16495940127e39 (diff)
downloadllvm-6156e562ef42ed25274c2894aedb22b909184771.tar.gz
llvm-6156e562ef42ed25274c2894aedb22b909184771.tar.bz2
llvm-6156e562ef42ed25274c2894aedb22b909184771.tar.xz
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
Diffstat (limited to 'lib/Bitcode/Reader/BitcodeReader.h')
0 files changed, 0 insertions, 0 deletions