diff options
| author | Jingyue Wu <jingyue@google.com> | 2014-10-25 17:36:21 +0000 |
|---|---|---|
| committer | Jingyue Wu <jingyue@google.com> | 2014-10-25 17:36:21 +0000 |
| commit | b723152379709d4bc4e5d91a92c48b509880e9f2 (patch) | |
| tree | 9be7a834608d8c12b25b86490b33441416fcb3ce /llvm/test/Transforms/SeparateConstOffsetFromGEP | |
| parent | d3c3e78ac17602420ca05b1ce1ed7d20ba9c5ede (diff) | |
| download | bcm5719-llvm-b723152379709d4bc4e5d91a92c48b509880e9f2.tar.gz bcm5719-llvm-b723152379709d4bc4e5d91a92c48b509880e9f2.zip | |
[SeparateConstOffsetFromGEP] Fixed a bug in rebuilding OR expressions
The two operands of the new OR expression should be NextInChain and TheOther
instead of the two original operands.
Added a regression test in split-gep.ll.
Hao Liu reported this bug, and provded the test case and an initial patch.
Thanks!
llvm-svn: 220615
Diffstat (limited to 'llvm/test/Transforms/SeparateConstOffsetFromGEP')
| -rw-r--r-- | llvm/test/Transforms/SeparateConstOffsetFromGEP/NVPTX/split-gep.ll | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/test/Transforms/SeparateConstOffsetFromGEP/NVPTX/split-gep.ll b/llvm/test/Transforms/SeparateConstOffsetFromGEP/NVPTX/split-gep.ll index 1784171454d..4d07ab35b51 100644 --- a/llvm/test/Transforms/SeparateConstOffsetFromGEP/NVPTX/split-gep.ll +++ b/llvm/test/Transforms/SeparateConstOffsetFromGEP/NVPTX/split-gep.ll @@ -234,3 +234,22 @@ entry: ; CHECK-LABEL: @and( ; CHECK: getelementptr [32 x [32 x float]]* @float_2d_array ; CHECK-NOT: getelementptr + +; The code that rebuilds an OR expression used to be buggy, and failed on this +; test. +define float* @shl_add_or(i64 %a, float* %ptr) { +; CHECK-LABEL: @shl_add_or( +entry: + %shl = shl i64 %a, 2 + %add = add i64 %shl, 12 + %or = or i64 %add, 1 +; CHECK: [[OR:%or[0-9]*]] = add i64 %shl, 1 + ; ((a << 2) + 12) and 1 have no common bits. Therefore, + ; SeparateConstOffsetFromGEP is able to extract the 12. + ; TODO(jingyue): We could reassociate the expression to combine 12 and 1. + %p = getelementptr float* %ptr, i64 %or +; CHECK: [[PTR:%[a-zA-Z0-9]+]] = getelementptr float* %ptr, i64 [[OR]] +; CHECK: getelementptr float* [[PTR]], i64 12 + ret float* %p +; CHECK-NEXT: ret +} |

