[llvm] 6d8d9fc - [InstCombine] Add test for icmp of pointers with known bits (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 12 06:08:14 PST 2024


Author: Nikita Popov
Date: 2024-11-12T15:07:48+01:00
New Revision: 6d8d9fc8d279623cca94b2b875a92517ed308f18

URL: https://github.com/llvm/llvm-project/commit/6d8d9fc8d279623cca94b2b875a92517ed308f18
DIFF: https://github.com/llvm/llvm-project/commit/6d8d9fc8d279623cca94b2b875a92517ed308f18.diff

LOG: [InstCombine] Add test for icmp of pointers with known bits (NFC)

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/icmp-gep.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/icmp-gep.ll b/llvm/test/Transforms/InstCombine/icmp-gep.ll
index 01bee5a0f9cbd5..887cf1162319bc 100644
--- a/llvm/test/Transforms/InstCombine/icmp-gep.ll
+++ b/llvm/test/Transforms/InstCombine/icmp-gep.ll
@@ -580,3 +580,25 @@ define i1 @gep_nusw(ptr %p, i64 %a, i64 %b, i64 %c, i64 %d) {
   %cmp = icmp eq ptr %gep1, %gep2
   ret i1 %cmp
 }
+
+define i1 @pointer_icmp_aligned_with_offset(ptr align 8 %a, ptr align 8 %a2) {
+; CHECK-LABEL: @pointer_icmp_aligned_with_offset(
+; CHECK-NEXT:    [[GEP:%.*]] = getelementptr i8, ptr [[A:%.*]], i64 4
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq ptr [[GEP]], [[A2:%.*]]
+; CHECK-NEXT:    ret i1 [[CMP]]
+;
+  %gep = getelementptr i8, ptr %a, i64 4
+  %cmp = icmp eq ptr %gep, %a2
+  ret i1 %cmp
+}
+
+define i1 @pointer_icmp_aligned_with_offset_negative(ptr align 8 %a, ptr align 8 %a2) {
+; CHECK-LABEL: @pointer_icmp_aligned_with_offset_negative(
+; CHECK-NEXT:    [[GEP:%.*]] = getelementptr i8, ptr [[A:%.*]], i64 8
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq ptr [[GEP]], [[A2:%.*]]
+; CHECK-NEXT:    ret i1 [[CMP]]
+;
+  %gep = getelementptr i8, ptr %a, i64 8
+  %cmp = icmp eq ptr %gep, %a2
+  ret i1 %cmp
+}


        


More information about the llvm-commits mailing list