1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=newgvn -S | FileCheck %s
3 target datalayout = "E-m:e-i64:64-n32:64"
5 @global = external hidden unnamed_addr constant [11 x i8], align 1
6 ;; Ensure we do not believe the indexing increments are unreachable due to incorrect memory
7 ;; equivalence detection. In PR31483, we were deleting those blocks as unreachable
8 ; Function Attrs: nounwind
9 define signext i32 @ham(ptr %arg, ptr %arg1) #0 {
12 ; CHECK-NEXT: [[TMP:%.*]] = alloca ptr, align 8
13 ; CHECK-NEXT: store ptr %arg1, ptr [[TMP]], align 8
14 ; CHECK-NEXT: br label %bb2
16 ; CHECK-NEXT: [[TMP3:%.*]] = phi ptr [ %arg, %bb ], [ %tmp7, %bb22 ]
17 ; CHECK-NEXT: [[TMP4:%.*]] = load i8, ptr [[TMP3]], align 1
18 ; CHECK-NEXT: [[TMP5:%.*]] = icmp ne i8 [[TMP4]], 0
19 ; CHECK-NEXT: br i1 [[TMP5]], label %bb6, label %bb23
21 ; CHECK-NEXT: [[TMP7:%.*]] = getelementptr inbounds i8, ptr [[TMP3]], i32 1
22 ; CHECK-NEXT: [[TMP9:%.*]] = zext i8 [[TMP4]] to i32
23 ; CHECK-NEXT: switch i32 [[TMP9]], label %bb22 [
24 ; CHECK-NEXT: i32 115, label %bb10
25 ; CHECK-NEXT: i32 105, label %bb16
26 ; CHECK-NEXT: i32 99, label %bb16
29 ; CHECK-NEXT: [[TMP11:%.*]] = load ptr, ptr [[TMP]], align 8
30 ; CHECK-NEXT: [[TMP12:%.*]] = getelementptr inbounds i8, ptr [[TMP11]], i64 8
31 ; CHECK-NEXT: store ptr [[TMP12]], ptr [[TMP]], align 8
32 ; CHECK-NEXT: [[TMP14:%.*]] = load ptr, ptr [[TMP11]], align 8
33 ; CHECK-NEXT: [[TMP15:%.*]] = call signext i32 (ptr, ...) @zot(ptr @global, ptr [[TMP14]])
34 ; CHECK-NEXT: br label %bb22
36 ; CHECK-NEXT: [[TMP17:%.*]] = load ptr, ptr [[TMP]], align 8
37 ; CHECK-NEXT: [[TMP18:%.*]] = getelementptr inbounds i8, ptr [[TMP17]], i64 8
38 ; CHECK-NEXT: store ptr [[TMP18]], ptr [[TMP]], align 8
39 ; CHECK-NEXT: [[TMP19:%.*]] = getelementptr inbounds i8, ptr [[TMP17]], i64 4
40 ; CHECK-NEXT: br label %bb22
42 ; CHECK-NEXT: br label %bb2
44 ; CHECK-NEXT: call void @llvm.va_end(ptr [[TMP]])
45 ; CHECK-NEXT: ret i32 undef
48 %tmp = alloca ptr, align 8
49 store ptr %arg1, ptr %tmp, align 8
52 bb2: ; preds = %bb22, %bb
53 %tmp3 = phi ptr [ %arg, %bb ], [ %tmp7, %bb22 ]
54 %tmp4 = load i8, ptr %tmp3, align 1
55 %tmp5 = icmp ne i8 %tmp4, 0
56 br i1 %tmp5, label %bb6, label %bb23
59 %tmp7 = getelementptr inbounds i8, ptr %tmp3, i32 1
60 %tmp8 = load i8, ptr %tmp3, align 1
61 %tmp9 = zext i8 %tmp8 to i32
62 switch i32 %tmp9, label %bb22 [
69 %tmp11 = load ptr, ptr %tmp, align 8
70 %tmp12 = getelementptr inbounds i8, ptr %tmp11, i64 8
71 store ptr %tmp12, ptr %tmp, align 8
72 %tmp14 = load ptr, ptr %tmp11, align 8
73 %tmp15 = call signext i32 (ptr, ...) @zot(ptr @global, ptr %tmp14)
76 bb16: ; preds = %bb6, %bb6
77 %tmp17 = load ptr, ptr %tmp, align 8
78 %tmp18 = getelementptr inbounds i8, ptr %tmp17, i64 8
79 store ptr %tmp18, ptr %tmp, align 8
80 %tmp19 = getelementptr inbounds i8, ptr %tmp17, i64 4
81 %tmp21 = load i32, ptr %tmp19, align 4
84 bb22: ; preds = %bb16, %bb10, %bb6
88 call void @llvm.va_end(ptr %tmp)
92 declare signext i32 @zot(ptr, ...) #1
94 ; Function Attrs: nounwind
95 declare void @llvm.va_end(ptr) #2
97 attributes #0 = { nounwind "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="ppc64" "target-features"="+altivec,-bpermd,-crypto,-direct-move,-extdiv,-power8-vector,-vsx" "unsafe-fp-math"="false" "use-soft-float"="false" }
98 attributes #1 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="ppc64" "target-features"="+altivec,-bpermd,-crypto,-direct-move,-extdiv,-power8-vector,-vsx" "unsafe-fp-math"="false" "use-soft-float"="false" }
99 attributes #2 = { nounwind }