%cmp = icmp ult i8 (...)* bitcast (i1 (i8*)* @ugt_null_constexpr to i8 (...)*), inttoptr (i32 1 to i8 (...)*)
ret i1 %cmp
}
+
+@g = global [2 x i32] [i32 1, i32 2]
+@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
+}