From: Nikita Popov Date: Fri, 1 Jan 2021 16:00:02 +0000 (+0100) Subject: [InstSimplify] Add tests for gep p, -p without inbounds (NFC) X-Git-Tag: llvmorg-13-init~2274 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=26680269e0ed17eb46e9bf10faa4116152608a51;p=platform%2Fupstream%2Fllvm.git [InstSimplify] Add tests for gep p, -p without inbounds (NFC) This is additional test coverage for D93820. --- diff --git a/llvm/test/Transforms/InstSimplify/gep.ll b/llvm/test/Transforms/InstSimplify/gep.ll index a079909..f60f0cb 100644 --- a/llvm/test/Transforms/InstSimplify/gep.ll +++ b/llvm/test/Transforms/InstSimplify/gep.ll @@ -47,6 +47,17 @@ define %struct.A* @test4(%struct.A* %b) { %b_ptr = ptrtoint %struct.A* %b to i64 %sub = sub i64 0, %b_ptr %sdiv = sdiv exact i64 %sub, 7 + %gep = getelementptr %struct.A, %struct.A* %b, i64 %sdiv + ret %struct.A* %gep +} + +define %struct.A* @test4_inbounds(%struct.A* %b) { +; CHECK-LABEL: @test4_inbounds( +; CHECK-NEXT: ret %struct.A* null +; + %b_ptr = ptrtoint %struct.A* %b to i64 + %sub = sub i64 0, %b_ptr + %sdiv = sdiv exact i64 %sub, 7 %gep = getelementptr inbounds %struct.A, %struct.A* %b, i64 %sdiv ret %struct.A* %gep } @@ -57,6 +68,16 @@ define i8* @test5(i8* %b) { ; %b_ptr = ptrtoint i8* %b to i64 %sub = sub i64 0, %b_ptr + %gep = getelementptr i8, i8* %b, i64 %sub + ret i8* %gep +} + +define i8* @test5_inbounds(i8* %b) { +; CHECK-LABEL: @test5_inbounds( +; CHECK-NEXT: ret i8* null +; + %b_ptr = ptrtoint i8* %b to i64 + %sub = sub i64 0, %b_ptr %gep = getelementptr inbounds i8, i8* %b, i64 %sub ret i8* %gep } @@ -68,6 +89,17 @@ define i64* @test6(i64* %b) { %b_ptr = ptrtoint i64* %b to i64 %sub = sub i64 0, %b_ptr %ashr = ashr exact i64 %sub, 3 + %gep = getelementptr i64, i64* %b, i64 %ashr + ret i64* %gep +} + +define i64* @test6_inbounds(i64* %b) { +; CHECK-LABEL: @test6_inbounds( +; CHECK-NEXT: ret i64* null +; + %b_ptr = ptrtoint i64* %b to i64 + %sub = sub i64 0, %b_ptr + %ashr = ashr exact i64 %sub, 3 %gep = getelementptr inbounds i64, i64* %b, i64 %ashr ret i64* %gep }