1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2 ; RUN: opt < %s -loop-reduce -S | FileCheck %s
3 ; RUN: opt -passes='require<scalar-evolution>,require<targetir>,loop(loop-reduce)' < %s -S | FileCheck %s
5 ; PR11782: bad cast to AddRecExpr.
6 ; A sign extend feeds an IVUser and cannot be hoisted into the AddRec.
7 ; CollectIVChains should bailout on this case.
10 ; Provide legal integer types.
11 target datalayout = "n8:16:32:64"
13 %struct = type { ptr, ptr, i16, i64, i16, i16, i16, i64, i64, i16, ptr, i64, i64, i64 }
15 define i32 @test(ptr %h, i32 %more) nounwind uwtable {
16 ; CHECK-LABEL: define i32 @test
17 ; CHECK-SAME: (ptr [[H:%.*]], i32 [[MORE:%.*]]) #[[ATTR0:[0-9]+]] {
19 ; CHECK-NEXT: br i1 undef, label [[LAND_END238:%.*]], label [[RETURN:%.*]]
21 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
23 ; CHECK-NEXT: [[LSR_IV:%.*]] = phi ptr [ [[SCEVGEP:%.*]], [[SW_EPILOG:%.*]] ], [ undef, [[LAND_END238]] ]
24 ; CHECK-NEXT: [[COLUMN_N_0:%.*]] = phi i16 [ 0, [[LAND_END238]] ], [ [[INC601:%.*]], [[SW_EPILOG]] ]
25 ; CHECK-NEXT: [[CONV250:%.*]] = sext i16 [[COLUMN_N_0]] to i32
26 ; CHECK-NEXT: [[ADD257:%.*]] = add nsw i32 [[CONV250]], 1
27 ; CHECK-NEXT: [[CONV258:%.*]] = trunc i32 [[ADD257]] to i16
28 ; CHECK-NEXT: [[CMP263:%.*]] = icmp ult i16 undef, 2
29 ; CHECK-NEXT: br label [[IF_END388:%.*]]
31 ; CHECK-NEXT: [[CALL405:%.*]] = call signext i16 @SQLColAttribute(ptr undef, i16 zeroext [[CONV258]], i16 zeroext 1003, ptr null, i16 signext 0, ptr null, ptr [[LSR_IV]]) #[[ATTR1:[0-9]+]]
32 ; CHECK-NEXT: br label [[SW_EPILOG]]
34 ; CHECK-NEXT: [[INC601]] = add i16 [[COLUMN_N_0]], 1
35 ; CHECK-NEXT: [[SCEVGEP]] = getelementptr i8, ptr [[LSR_IV]], i64 88
36 ; CHECK-NEXT: br label [[FOR_BODY]]
38 ; CHECK-NEXT: ret i32 1
41 br i1 undef, label %land.end238, label %return
43 land.end238: ; preds = %if.end229
46 for.body: ; preds = %sw.epilog, %land.end238
47 %fbh.0 = phi ptr [ undef, %land.end238 ], [ %incdec.ptr, %sw.epilog ]
48 %column_n.0 = phi i16 [ 0, %land.end238 ], [ %inc601, %sw.epilog ]
49 %conv250 = sext i16 %column_n.0 to i32
50 %add257 = add nsw i32 %conv250, 1
51 %conv258 = trunc i32 %add257 to i16
52 %cmp263 = icmp ult i16 undef, 2
55 if.end388: ; preds = %if.then380, %if.else356
56 %ColLength = getelementptr inbounds %struct, ptr %fbh.0, i64 0, i32 7
57 %call405 = call signext i16 @SQLColAttribute(ptr undef, i16 zeroext %conv258, i16 zeroext 1003, ptr null, i16 signext 0, ptr null, ptr %ColLength) nounwind
60 sw.epilog: ; preds = %sw.bb542, %sw.bb523, %if.end475
61 %inc601 = add i16 %column_n.0, 1
62 %incdec.ptr = getelementptr inbounds %struct, ptr %fbh.0, i64 1
65 return: ; preds = %entry
69 declare signext i16 @SQLColAttribute(ptr, i16 zeroext, i16 zeroext, ptr, i16 signext, ptr, ptr)