Avoid combining GEPs that might overflow at runtime.
[oota-llvm.git] / test / Transforms / InstCombine / 2011-05-13-InBoundsGEP.ll
1 ; RUN: opt < %s -instcombine | lli
2 ; rdar://problem/9267970
3 ; ideally this test will run on a 32-bit host
4 ; must not discard GEPs that might overflow at runtime (aren't inbounds)
5
6 define i32 @main(i32 %argc) {
7 entry:
8     %tmp1 = add i32 %argc, -2
9     %tmp2 = add i32 %argc, 1879048192
10     %p = alloca i8
11     %p1 = getelementptr i8* %p, i32 %tmp1
12     %p2 = getelementptr i8* %p, i32 %tmp2
13     %cmp = icmp ult i8* %p1, %p2
14     br i1 %cmp, label %bbtrue, label %bbfalse
15 bbtrue:          ; preds = %entry
16     ret i32 -1
17 bbfalse:         ; preds = %entry
18     ret i32 0
19 }