1 ; RUN: opt -march=hexagon -hexagon-loop-idiom -S < %s | FileCheck %s
3 ; The number of nested selects caused the simplification loop to take
4 ; more than the maximum number of iterations. This caused the compiler
5 ; to crash under suspicion of an infinite loop. This (still reduced)
6 ; testcase shows a legitimate case where this limit was exceeded.
7 ; Instead of crashing, gracefully abort the simplification.
9 ; Check for sane output.
10 ; CHECK: define void @fred
12 target datalayout = "e-m:e-p:32:32:32-a:0-n16:32-i64:64:64-i32:32:32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-v32:32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048:2048:2048"
13 target triple = "hexagon"
15 define void @fred() unnamed_addr #0 {
17 %v1 = select i1 false, i32 undef, i32 2
20 b2: ; preds = %b2, %b0
21 %v3 = sext i16 undef to i32
22 %v4 = add nsw i32 %v1, %v3
23 %v5 = select i1 undef, i32 undef, i32 %v4
24 %v6 = icmp slt i32 %v5, undef
25 %v7 = select i1 %v6, i32 %v5, i32 undef
26 %v8 = icmp slt i32 %v7, 0
27 %v9 = select i1 %v8, i32 %v7, i32 0
28 %v10 = sub i32 undef, undef
29 %v11 = add i32 %v10, %v9
30 %v12 = sext i16 undef to i32
31 %v13 = sext i16 undef to i32
32 %v14 = add nsw i32 %v1, %v13
33 %v15 = select i1 undef, i32 undef, i32 %v14
34 %v16 = icmp slt i32 %v15, undef
35 %v17 = select i1 %v16, i32 %v15, i32 undef
36 %v18 = select i1 undef, i32 %v17, i32 %v12
37 %v19 = add i32 undef, %v18
38 %v20 = sext i16 undef to i32
39 %v21 = sext i16 0 to i32
40 %v22 = add nsw i32 %v1, %v21
41 %v23 = sext i16 undef to i32
42 %v24 = add nsw i32 %v1, %v23
43 %v25 = select i1 undef, i32 undef, i32 %v24
44 %v26 = icmp slt i32 %v25, %v22
45 %v27 = select i1 %v26, i32 %v25, i32 %v22
46 %v28 = icmp slt i32 %v27, %v20
47 %v29 = select i1 %v28, i32 %v27, i32 %v20
48 %v30 = add i32 undef, %v29
49 %v31 = add i32 %v11, undef
50 %v32 = add i32 %v31, undef
51 %v33 = add i32 %v32, %v19
52 %v34 = add i32 %v33, %v30
53 %v35 = add nsw i32 %v34, 32768
54 %v36 = icmp ult i32 %v35, 65536
55 %v37 = select i1 %v36, i32 %v34, i32 undef
56 br i1 undef, label %b2, label %b38
62 attributes #0 = { "target-cpu"="hexagonv60" }