1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=constraint-elimination -S %s | FileCheck %s
4 target datalayout = "p:32:32:32"
6 declare void @llvm.assume(i1)
8 define i1 @gep_idx_implicit_truncate(ptr %dst, i64 %off) {
9 ; CHECK-LABEL: @gep_idx_implicit_truncate(
10 ; CHECK-NEXT: [[POS:%.*]] = icmp sge i64 [[OFF:%.*]], 0
11 ; CHECK-NEXT: call void @llvm.assume(i1 [[POS]])
12 ; CHECK-NEXT: [[GEP_OFF:%.*]] = getelementptr inbounds i8, ptr [[DST:%.*]], i64 [[OFF]]
13 ; CHECK-NEXT: ret i1 true
15 %pos = icmp sge i64 %off, 0
16 call void @llvm.assume(i1 %pos)
17 %gep.off = getelementptr inbounds i8, ptr %dst, i64 %off
18 %cmp = icmp ule ptr %dst, %gep.off
22 define i1 @gep_idx_explicit_truncate(ptr %dst, i64 %off) {
23 ; CHECK-LABEL: @gep_idx_explicit_truncate(
24 ; CHECK-NEXT: [[POS:%.*]] = icmp sge i64 [[OFF:%.*]], 0
25 ; CHECK-NEXT: call void @llvm.assume(i1 [[POS]])
26 ; CHECK-NEXT: [[T:%.*]] = trunc i64 [[OFF]] to i32
27 ; CHECK-NEXT: [[GEP_OFF:%.*]] = getelementptr inbounds i8, ptr [[DST:%.*]], i32 [[T]]
28 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule ptr [[DST]], [[GEP_OFF]]
29 ; CHECK-NEXT: ret i1 [[CMP]]
31 %pos = icmp sge i64 %off, 0
32 call void @llvm.assume(i1 %pos)
33 %t = trunc i64 %off to i32
34 %gep.off = getelementptr inbounds i8, ptr %dst, i32 %t
35 %cmp = icmp ule ptr %dst, %gep.off