[llvm] 2ef03bc - [ConstProp] Add more tests for pointer icmp folding (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 8 08:06:26 PST 2021
Author: Nikita Popov
Date: 2021-03-08T17:06:12+01:00
New Revision: 2ef03bc3a83f67a98d82a03a0c0f7ac9caf2426f
URL: https://github.com/llvm/llvm-project/commit/2ef03bc3a83f67a98d82a03a0c0f7ac9caf2426f
DIFF: https://github.com/llvm/llvm-project/commit/2ef03bc3a83f67a98d82a03a0c0f7ac9caf2426f.diff
LOG: [ConstProp] Add more tests for pointer icmp folding (NFC)
Added:
Modified:
llvm/test/Transforms/InstSimplify/ConstProp/icmp-null.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstSimplify/ConstProp/icmp-null.ll b/llvm/test/Transforms/InstSimplify/ConstProp/icmp-null.ll
index c1bef60b347f..46fd8c4bfce8 100644
--- a/llvm/test/Transforms/InstSimplify/ConstProp/icmp-null.ll
+++ b/llvm/test/Transforms/InstSimplify/ConstProp/icmp-null.ll
@@ -62,3 +62,156 @@ define i1 @ult_constexpr_constexpr_one(i8* %x) {
%cmp = icmp ult i8 (...)* bitcast (i1 (i8*)* @ugt_null_constexpr to i8 (...)*), inttoptr (i32 1 to i8 (...)*)
ret i1 %cmp
}
+
+ at g = global [2 x i32] [i32 1, i32 2]
+ at g2 = global i32 0
+
+define i1 @global_ne_null() {
+; CHECK-LABEL: @global_ne_null(
+; CHECK-NEXT: ret i1 true
+;
+ %cmp = icmp ne [2 x i32]* @g, null
+ ret i1 %cmp
+}
+
+define i1 @global_ugt_null() {
+; CHECK-LABEL: @global_ugt_null(
+; CHECK-NEXT: ret i1 icmp ugt ([2 x i32]* @g, [2 x i32]* null)
+;
+ %cmp = icmp ugt [2 x i32]* @g, null
+ ret i1 %cmp
+}
+
+define i1 @global_sgt_null() {
+; CHECK-LABEL: @global_sgt_null(
+; CHECK-NEXT: ret i1 icmp sgt ([2 x i32]* @g, [2 x i32]* null)
+;
+ %cmp = icmp sgt [2 x i32]* @g, null
+ ret i1 %cmp
+}
+
+define i1 @global_gep_ne_null() {
+; CHECK-LABEL: @global_gep_ne_null(
+; CHECK-NEXT: ret i1 true
+;
+ %gep = getelementptr inbounds [2 x i32], [2 x i32]* @g, i64 1
+ %cmp = icmp ne [2 x i32]* %gep, null
+ ret i1 %cmp
+}
+
+define i1 @global_gep_ugt_null() {
+; CHECK-LABEL: @global_gep_ugt_null(
+; CHECK-NEXT: ret i1 true
+;
+ %gep = getelementptr inbounds [2 x i32], [2 x i32]* @g, i64 1
+ %cmp = icmp ugt [2 x i32]* %gep, null
+ ret i1 %cmp
+}
+
+define i1 @global_gep_sgt_null() {
+; CHECK-LABEL: @global_gep_sgt_null(
+; CHECK-NEXT: ret i1 true
+;
+ %gep = getelementptr inbounds [2 x i32], [2 x i32]* @g, i64 1
+ %cmp = icmp sgt [2 x i32]* %gep, null
+ ret i1 %cmp
+}
+
+define i1 @null_gep_ne_null() {
+; CHECK-LABEL: @null_gep_ne_null(
+; CHECK-NEXT: ret i1 true
+;
+ %gep = getelementptr i8, i8* null, i64 ptrtoint (i32* @g2 to i64)
+ %cmp = icmp ne i8* %gep, null
+ ret i1 %cmp
+}
+
+define i1 @null_gep_ugt_null() {
+; CHECK-LABEL: @null_gep_ugt_null(
+; CHECK-NEXT: ret i1 true
+;
+ %gep = getelementptr i8, i8* null, i64 ptrtoint (i32* @g2 to i64)
+ %cmp = icmp ugt i8* %gep, null
+ ret i1 %cmp
+}
+
+define i1 @null_gep_sgt_null() {
+; CHECK-LABEL: @null_gep_sgt_null(
+; CHECK-NEXT: ret i1 true
+;
+ %gep = getelementptr i8, i8* null, i64 ptrtoint (i32* @g2 to i64)
+ %cmp = icmp sgt i8* %gep, null
+ ret i1 %cmp
+}
+
+define i1 @null_gep_ne_global() {
+; CHECK-LABEL: @null_gep_ne_global(
+; CHECK-NEXT: ret i1 true
+;
+ %gep = getelementptr [2 x i32], [2 x i32]* null, i64 ptrtoint (i32* @g2 to i64)
+ %cmp = icmp ne [2 x i32]* %gep, @g
+ ret i1 %cmp
+}
+
+define i1 @null_gep_ult_global() {
+; CHECK-LABEL: @null_gep_ult_global(
+; CHECK-NEXT: ret i1 true
+;
+ %gep = getelementptr [2 x i32], [2 x i32]* null, i64 ptrtoint (i32* @g2 to i64)
+ %cmp = icmp ult [2 x i32]* %gep, @g
+ ret i1 %cmp
+}
+
+define i1 @null_gep_slt_global() {
+; CHECK-LABEL: @null_gep_slt_global(
+; CHECK-NEXT: ret i1 true
+;
+ %gep = getelementptr [2 x i32], [2 x i32]* null, i64 ptrtoint (i32* @g2 to i64)
+ %cmp = icmp slt [2 x i32]* %gep, @g
+ ret i1 %cmp
+}
+
+define i1 @global_gep_ne_global() {
+; CHECK-LABEL: @global_gep_ne_global(
+; CHECK-NEXT: ret i1 true
+;
+ %gep = getelementptr inbounds [2 x i32], [2 x i32]* @g, i64 1
+ %cmp = icmp ne [2 x i32]* %gep, @g
+ ret i1 %cmp
+}
+
+define i1 @global_gep_ugt_global() {
+; CHECK-LABEL: @global_gep_ugt_global(
+; CHECK-NEXT: ret i1 true
+;
+ %gep = getelementptr inbounds [2 x i32], [2 x i32]* @g, i64 1
+ %cmp = icmp ugt [2 x i32]* %gep, @g
+ ret i1 %cmp
+}
+
+define i1 @global_gep_sgt_global() {
+; CHECK-LABEL: @global_gep_sgt_global(
+; CHECK-NEXT: ret i1 true
+;
+ %gep = getelementptr inbounds [2 x i32], [2 x i32]* @g, i64 1
+ %cmp = icmp sgt [2 x i32]* %gep, @g
+ ret i1 %cmp
+}
+
+define i1 @global_gep_ugt_global_neg_offset() {
+; CHECK-LABEL: @global_gep_ugt_global_neg_offset(
+; CHECK-NEXT: ret i1 true
+;
+ %gep = getelementptr [2 x i32], [2 x i32]* @g, i64 -1
+ %cmp = icmp ugt [2 x i32]* %gep, @g
+ ret i1 %cmp
+}
+
+define i1 @global_gep_sgt_global_neg_offset() {
+; CHECK-LABEL: @global_gep_sgt_global_neg_offset(
+; CHECK-NEXT: ret i1 true
+;
+ %gep = getelementptr [2 x i32], [2 x i32]* @g, i64 -1
+ %cmp = icmp sgt [2 x i32]* %gep, @g
+ ret i1 %cmp
+}
More information about the llvm-commits
mailing list