1; RUN: llc -verify-machineinstrs -mtriple=i386--netbsd < %s | FileCheck %s
2; Regression test for http://reviews.llvm.org/D5701
3
4; ModuleID = 'xxhash.i'
5target datalayout = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128"
6target triple = "i386--netbsd"
7
8; CHECK-LABEL: fn1
9; CHECK:       shldl {{.*#+}} 4-byte Folded Spill
10; CHECK:       orl   {{.*#+}} 4-byte Folded Reload
11; CHECK:       shldl {{.*#+}} 4-byte Folded Spill
12; CHECK:       orl   {{.*#+}} 4-byte Folded Reload
13; CHECK:       addl  {{.*#+}} 4-byte Folded Reload
14; CHECK:       imull {{.*#+}} 4-byte Folded Reload
15; CHECK:       orl   {{.*#+}} 4-byte Folded Reload
16; CHECK:       retl
17
18%struct.XXH_state64_t = type { i32, i32, i64, i64, i64 }
19
20@a = common global i32 0, align 4
21@b = common global i64 0, align 8
22
23; Function Attrs: nounwind uwtable
24define i64 @fn1() #0 {
25entry:
26  %0 = load i32, i32* @a, align 4, !tbaa !1
27  %1 = inttoptr i32 %0 to %struct.XXH_state64_t*
28  %total_len = getelementptr inbounds %struct.XXH_state64_t, %struct.XXH_state64_t* %1, i32 0, i32 0
29  %2 = load i32, i32* %total_len, align 4, !tbaa !5
30  %tobool = icmp eq i32 %2, 0
31  br i1 %tobool, label %if.else, label %if.then
32
33if.then:                                          ; preds = %entry
34  %v3 = getelementptr inbounds %struct.XXH_state64_t, %struct.XXH_state64_t* %1, i32 0, i32 3
35  %3 = load i64, i64* %v3, align 4, !tbaa !8
36  %v4 = getelementptr inbounds %struct.XXH_state64_t, %struct.XXH_state64_t* %1, i32 0, i32 4
37  %4 = load i64, i64* %v4, align 4, !tbaa !9
38  %v2 = getelementptr inbounds %struct.XXH_state64_t, %struct.XXH_state64_t* %1, i32 0, i32 2
39  %5 = load i64, i64* %v2, align 4, !tbaa !10
40  %shl = shl i64 %5, 1
41  %or = or i64 %shl, %5
42  %shl2 = shl i64 %3, 2
43  %shr = lshr i64 %3, 1
44  %or3 = or i64 %shl2, %shr
45  %add = add i64 %or, %or3
46  %mul = mul i64 %4, -4417276706812531889
47  %shl4 = mul i64 %4, -8834553413625063778
48  %shr5 = ashr i64 %mul, 3
49  %or6 = or i64 %shr5, %shl4
50  %mul7 = mul nsw i64 %or6, 1400714785074694791
51  %xor = xor i64 %add, %mul7
52  store i64 %xor, i64* @b, align 8, !tbaa !11
53  %mul8 = mul nsw i64 %xor, 1400714785074694791
54  br label %if.end
55
56if.else:                                          ; preds = %entry
57  %6 = load i64, i64* @b, align 8, !tbaa !11
58  %xor10 = xor i64 %6, -4417276706812531889
59  %mul11 = mul nsw i64 %xor10, 400714785074694791
60  br label %if.end
61
62if.end:                                           ; preds = %if.else, %if.then
63  %storemerge.in = phi i64 [ %mul11, %if.else ], [ %mul8, %if.then ]
64  %storemerge = add i64 %storemerge.in, -8796714831421723037
65  store i64 %storemerge, i64* @b, align 8, !tbaa !11
66  ret i64 undef
67}
68
69attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
70
71!llvm.ident = !{!0}
72
73!0 = !{!"clang version 3.6 (trunk 219587)"}
74!1 = !{!2, !2, i64 0}
75!2 = !{!"int", !3, i64 0}
76!3 = !{!"omnipotent char", !4, i64 0}
77!4 = !{!"Simple C/C++ TBAA"}
78!5 = !{!6, !2, i64 0}
79!6 = !{!"XXH_state64_t", !2, i64 0, !2, i64 4, !7, i64 8, !7, i64 16, !7, i64 24}
80!7 = !{!"long long", !3, i64 0}
81!8 = !{!6, !7, i64 16}
82!9 = !{!6, !7, i64 24}
83!10 = !{!6, !7, i64 8}
84!11 = !{!7, !7, i64 0}
85