[llvm-branch-commits] [llvm] 2668026 - [InstSimplify] Add tests for gep p, -p without inbounds (NFC)
Nikita Popov via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Jan 1 08:06:24 PST 2021
Author: Nikita Popov
Date: 2021-01-01T17:00:02+01:00
New Revision: 26680269e0ed17eb46e9bf10faa4116152608a51
URL: https://github.com/llvm/llvm-project/commit/26680269e0ed17eb46e9bf10faa4116152608a51
DIFF: https://github.com/llvm/llvm-project/commit/26680269e0ed17eb46e9bf10faa4116152608a51.diff
LOG: [InstSimplify] Add tests for gep p, -p without inbounds (NFC)
This is additional test coverage for D93820.
Added:
Modified:
llvm/test/Transforms/InstSimplify/gep.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstSimplify/gep.ll b/llvm/test/Transforms/InstSimplify/gep.ll
index a0799090fc03..f60f0cb7fdca 100644
--- a/llvm/test/Transforms/InstSimplify/gep.ll
+++ b/llvm/test/Transforms/InstSimplify/gep.ll
@@ -43,6 +43,17 @@ define i64* @test3(i64* %b, i64* %e) {
define %struct.A* @test4(%struct.A* %b) {
; CHECK-LABEL: @test4(
; 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 %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
@@ -54,6 +65,16 @@ define %struct.A* @test4(%struct.A* %b) {
define i8* @test5(i8* %b) {
; CHECK-LABEL: @test5(
; CHECK-NEXT: ret i8* null
+;
+ %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
@@ -64,6 +85,17 @@ define i8* @test5(i8* %b) {
define i64* @test6(i64* %b) {
; CHECK-LABEL: @test6(
; 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 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
More information about the llvm-branch-commits
mailing list