X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=blobdiff_plain;f=test%2FTransforms%2FSeparateConstOffsetFromGEP%2FNVPTX%2Fsplit-gep.ll;fp=test%2FTransforms%2FSeparateConstOffsetFromGEP%2FNVPTX%2Fsplit-gep.ll;h=4d07ab35b51e53dfef0976c60b20a2d5d80a05fc;hp=1784171454d664f0cf1e554c0ca14977fb74246f;hb=5c50ab84b32d52f7053a53d2b76f95022e7c3ef3;hpb=c31aaa5a3fcef2851898fb30c61c16a70564079a diff --git a/test/Transforms/SeparateConstOffsetFromGEP/NVPTX/split-gep.ll b/test/Transforms/SeparateConstOffsetFromGEP/NVPTX/split-gep.ll index 1784171454d..4d07ab35b51 100644 --- a/test/Transforms/SeparateConstOffsetFromGEP/NVPTX/split-gep.ll +++ b/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 +}