1 ; NOTE: Assertions have been autogenerated by update_test_checks.py
2 ; RUN: opt < %s -instsimplify -S | FileCheck %s
3 target datalayout = "p:32:32"
5 ; Check some past-the-end subtleties.
10 ; Comparing base addresses of two distinct globals. Never equal.
12 define zeroext i1 @no_offsets() {
13 ; CHECK-LABEL: @no_offsets(
16 %t = icmp eq i32* @opte_a, @opte_b
20 ; Comparing past-the-end addresses of two distinct globals. Never equal.
22 define zeroext i1 @both_past_the_end() {
23 ; CHECK-LABEL: @both_past_the_end(
24 ; CHECK: ret i1 icmp eq (i32* getelementptr inbounds (i32, i32* @opte_a, i32 1), i32* getelementptr inbounds (i32, i32* @opte_b, i32 1))
26 %x = getelementptr i32, i32* @opte_a, i32 1
27 %y = getelementptr i32, i32* @opte_b, i32 1
28 %t = icmp eq i32* %x, %y
33 ; Comparing past-the-end addresses of one global to the base address
34 ; of another. Can't fold this.
36 define zeroext i1 @just_one_past_the_end() {
37 ; CHECK-LABEL: @just_one_past_the_end(
38 ; CHECK: ret i1 icmp eq (i32* getelementptr inbounds (i32, i32* @opte_a, i32 1), i32* @opte_b)
40 %x = getelementptr i32, i32* @opte_a, i32 1
41 %t = icmp eq i32* %x, @opte_b
45 ; Comparing base addresses of two distinct allocas. Never equal.
47 define zeroext i1 @no_alloca_offsets() {
48 ; CHECK-LABEL: @no_alloca_offsets(
53 %t = icmp eq i32* %m, %n
57 ; Comparing past-the-end addresses of two distinct allocas. Never equal.
59 define zeroext i1 @both_past_the_end_alloca() {
60 ; CHECK-LABEL: @both_past_the_end_alloca(
61 ; CHECK: [[M:%.*]] = alloca i32
62 ; CHECK-NEXT: [[N:%.*]] = alloca i32
63 ; CHECK-NEXT: [[X:%.*]] = getelementptr i32, i32* [[M]], i32 1
64 ; CHECK-NEXT: [[Y:%.*]] = getelementptr i32, i32* [[N]], i32 1
65 ; CHECK-NEXT: [[T:%.*]] = icmp eq i32* [[X]], [[Y]]
66 ; CHECK-NEXT: ret i1 [[T]]
70 %x = getelementptr i32, i32* %m, i32 1
71 %y = getelementptr i32, i32* %n, i32 1
72 %t = icmp eq i32* %x, %y
77 ; Comparing past-the-end addresses of one alloca to the base address
78 ; of another. Can't fold this.
80 define zeroext i1 @just_one_past_the_end_alloca() {
81 ; CHECK-LABEL: @just_one_past_the_end_alloca(
82 ; CHECK: [[M:%.*]] = alloca i32
83 ; CHECK-NEXT: [[N:%.*]] = alloca i32
84 ; CHECK-NEXT: [[X:%.*]] = getelementptr i32, i32* [[M]], i32 1
85 ; CHECK-NEXT: [[T:%.*]] = icmp eq i32* [[X]], [[N]]
86 ; CHECK-NEXT: ret i1 [[T]]
90 %x = getelementptr i32, i32* %m, i32 1
91 %t = icmp eq i32* %x, %n