1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=instcombine -S 2>&1 | FileCheck %s
3 target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
5 ; We are really checking that this doesn't loop forever. We would never
6 ; actually get to the checks here if it did.
8 define void @timeout(ptr nocapture readonly %cinfo, ptr %ptr) {
9 ; CHECK-LABEL: @timeout(
11 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
13 ; CHECK-NEXT: [[ARRAYIDX15:%.*]] = getelementptr inbounds nuw i8, ptr [[CINFO:%.*]], i32 4
14 ; CHECK-NEXT: [[L:%.*]] = load i16, ptr [[ARRAYIDX15]], align 2
15 ; CHECK-NEXT: [[CMP17:%.*]] = icmp eq i16 [[L]], 0
16 ; CHECK-NEXT: [[EXTRACT_T1:%.*]] = trunc i16 [[L]] to i8
17 ; CHECK-NEXT: br i1 [[CMP17]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
19 ; CHECK-NEXT: [[DOTPRE:%.*]] = load i16, ptr [[ARRAYIDX15]], align 2
20 ; CHECK-NEXT: [[EXTRACT_T:%.*]] = trunc i16 [[DOTPRE]] to i8
21 ; CHECK-NEXT: br label [[IF_END]]
23 ; CHECK-NEXT: [[P_OFF0:%.*]] = phi i8 [ [[EXTRACT_T]], [[IF_THEN]] ], [ [[EXTRACT_T1]], [[FOR_BODY]] ]
24 ; CHECK-NEXT: [[SUB:%.*]] = add i8 [[P_OFF0]], -1
25 ; CHECK-NEXT: store i8 [[SUB]], ptr [[PTR:%.*]], align 1
26 ; CHECK-NEXT: br label [[FOR_BODY]]
32 %arrayidx15 = getelementptr inbounds i16, ptr %cinfo, i32 2
33 %l = load i16, ptr %arrayidx15, align 2
34 %cmp17 = icmp eq i16 %l, 0
35 br i1 %cmp17, label %if.then, label %if.end
38 %.pre = load i16, ptr %arrayidx15, align 2
42 %p = phi i16 [ %.pre, %if.then ], [ %l, %for.body ]
43 %conv19 = trunc i16 %p to i8
44 %sub = add i8 %conv19, -1
45 store i8 %sub, ptr %ptr, align 1