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