From: Nikita Popov Date: Mon, 2 Jan 2023 14:17:34 +0000 (+0100) Subject: [InstCombine] Add tests for icmp of vector GEP (NFC) X-Git-Tag: upstream/17.0.6~22381 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a21458c7b0b9b51cd37bd87d083c7f239544304c;p=platform%2Fupstream%2Fllvm.git [InstCombine] Add tests for icmp of vector GEP (NFC) These show up as regressions with opaque pointers. --- diff --git a/llvm/test/Transforms/InstCombine/opaque-ptr.ll b/llvm/test/Transforms/InstCombine/opaque-ptr.ll index 2bfbeb5..a1e67e5 100644 --- a/llvm/test/Transforms/InstCombine/opaque-ptr.ll +++ b/llvm/test/Transforms/InstCombine/opaque-ptr.ll @@ -322,6 +322,38 @@ define i1 @compare_geps_same_indices_different_types(ptr %a, ptr %b, i64 %idx) { ret i1 %c } +define i1 @compare_gep_with_base(ptr %p, i64 %idx) { +; CHECK-LABEL: @compare_gep_with_base( +; CHECK-NEXT: [[C:%.*]] = icmp eq i64 [[IDX:%.*]], 0 +; CHECK-NEXT: ret i1 [[C]] +; + %gep = getelementptr inbounds i32, ptr %p, i64 %idx + %c = icmp eq ptr %gep, %p + ret i1 %c +} + +define <2 x i1> @compare_gep_with_base_vector1(<2 x ptr> %p, i64 %idx) { +; CHECK-LABEL: @compare_gep_with_base_vector1( +; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds i32, <2 x ptr> [[P:%.*]], i64 [[IDX:%.*]] +; CHECK-NEXT: [[C:%.*]] = icmp eq <2 x ptr> [[GEP]], [[P]] +; CHECK-NEXT: ret <2 x i1> [[C]] +; + %gep = getelementptr inbounds i32, <2 x ptr> %p, i64 %idx + %c = icmp eq <2 x ptr> %gep, %p + ret <2 x i1> %c +} + +define <2 x i1> @compare_gep_with_base_vector2(<2 x ptr> %p, <2 x i64> %idx) { +; CHECK-LABEL: @compare_gep_with_base_vector2( +; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds i32, <2 x ptr> [[P:%.*]], <2 x i64> [[IDX:%.*]] +; CHECK-NEXT: [[C:%.*]] = icmp eq <2 x ptr> [[GEP]], [[P]] +; CHECK-NEXT: ret <2 x i1> [[C]] +; + %gep = getelementptr inbounds i32, <2 x ptr> %p, <2 x i64> %idx + %c = icmp eq <2 x ptr> %gep, %p + ret <2 x i1> %c +} + define <4 x i1> @compare_geps_same_indices_scalar_vector_base_mismatch(ptr %ptr, <4 x ptr> %ptrs) { ; CHECK-LABEL: @compare_geps_same_indices_scalar_vector_base_mismatch( ; CHECK-NEXT: [[GEP1:%.*]] = getelementptr i16, <4 x ptr> [[PTRS:%.*]], <4 x i64>