[llvm] baac82b - [InstCombine] add tests for icmp of gep; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 1 07:53:29 PDT 2021
Author: Sanjay Patel
Date: 2021-10-01T10:53:23-04:00
New Revision: baac82b4cfbc4795e4e5e9e9e3576c968a612f8d
URL: https://github.com/llvm/llvm-project/commit/baac82b4cfbc4795e4e5e9e9e3576c968a612f8d
DIFF: https://github.com/llvm/llvm-project/commit/baac82b4cfbc4795e4e5e9e9e3576c968a612f8d.diff
LOG: [InstCombine] add tests for icmp of gep; 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 d8bbd394a026..4b5116c36f6f 100644
--- a/llvm/test/Transforms/InstCombine/icmp-gep.ll
+++ b/llvm/test/Transforms/InstCombine/icmp-gep.ll
@@ -174,6 +174,30 @@ define i1 @eq_base_inbounds_commute_use(i64 %y) {
ret i1 %r
}
+define i1 @eq_bitcast_base([2 x i8]* %p, i64 %x) {
+; CHECK-LABEL: @eq_bitcast_base(
+; CHECK-NEXT: [[GEP:%.*]] = getelementptr [2 x i8], [2 x i8]* [[P:%.*]], i64 [[X:%.*]], i64 0
+; CHECK-NEXT: [[B:%.*]] = getelementptr [2 x i8], [2 x i8]* [[P]], i64 0, i64 0
+; CHECK-NEXT: [[R:%.*]] = icmp eq i8* [[GEP]], [[B]]
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %gep = getelementptr [2 x i8], [2 x i8]* %p, i64 %x, i64 0
+ %b = bitcast [2 x i8]* %p to i8*
+ %r = icmp eq i8* %gep, %b
+ ret i1 %r
+}
+
+define i1 @eq_bitcast_base_inbounds([2 x i8]* %p, i64 %x) {
+; CHECK-LABEL: @eq_bitcast_base_inbounds(
+; CHECK-NEXT: [[R:%.*]] = icmp eq i64 [[X:%.*]], 0
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %gep = getelementptr inbounds [2 x i8], [2 x i8]* %p, i64 %x, i64 0
+ %b = bitcast [2 x i8]* %p to i8*
+ %r = icmp eq i8* %gep, %b
+ ret i1 %r
+}
+
@X = global [1000 x i32] zeroinitializer
define i1 @PR8882(i64 %i) {
More information about the llvm-commits
mailing list