1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -instcombine -instcombine-infinite-loop-threshold=2 < %s | FileCheck %s
4 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-pc-linux-gnu"
7 @a = dso_local local_unnamed_addr global i64 0, align 8
8 @d = dso_local local_unnamed_addr global i64 0, align 8
9 @c = external dso_local local_unnamed_addr global i8, align 1
11 define void @test(i16* nocapture readonly %arg) local_unnamed_addr {
14 ; CHECK-NEXT: [[I:%.*]] = load i64, i64* @d, align 8
15 ; CHECK-NEXT: [[I1:%.*]] = icmp eq i64 [[I]], 0
16 ; CHECK-NEXT: [[I2:%.*]] = load i64, i64* @a, align 8
17 ; CHECK-NEXT: [[I3:%.*]] = icmp ne i64 [[I2]], 0
18 ; CHECK-NEXT: br i1 [[I1]], label [[BB13:%.*]], label [[BB4:%.*]]
20 ; CHECK-NEXT: [[I5:%.*]] = load i16, i16* [[ARG:%.*]], align 2
21 ; CHECK-NEXT: [[I6:%.*]] = trunc i16 [[I5]] to i8
22 ; CHECK-NEXT: store i8 [[I6]], i8* @c, align 1
23 ; CHECK-NEXT: tail call void @llvm.assume(i1 [[I3]])
24 ; CHECK-NEXT: br label [[BB22:%.*]]
26 ; CHECK-NEXT: [[I14:%.*]] = load i16, i16* [[ARG]], align 2
27 ; CHECK-NEXT: [[I15:%.*]] = trunc i16 [[I14]] to i8
28 ; CHECK-NEXT: store i8 [[I15]], i8* @c, align 1
29 ; CHECK-NEXT: br label [[BB22]]
31 ; CHECK-NEXT: [[STOREMERGE2_IN:%.*]] = load i16, i16* [[ARG]], align 2
32 ; CHECK-NEXT: [[STOREMERGE2:%.*]] = trunc i16 [[STOREMERGE2_IN]] to i8
33 ; CHECK-NEXT: store i8 [[STOREMERGE2]], i8* @c, align 1
34 ; CHECK-NEXT: [[STOREMERGE1_IN:%.*]] = load i16, i16* [[ARG]], align 2
35 ; CHECK-NEXT: [[STOREMERGE1:%.*]] = trunc i16 [[STOREMERGE1_IN]] to i8
36 ; CHECK-NEXT: store i8 [[STOREMERGE1]], i8* @c, align 1
37 ; CHECK-NEXT: [[STOREMERGE_IN:%.*]] = load i16, i16* [[ARG]], align 2
38 ; CHECK-NEXT: [[STOREMERGE:%.*]] = trunc i16 [[STOREMERGE_IN]] to i8
39 ; CHECK-NEXT: store i8 [[STOREMERGE]], i8* @c, align 1
40 ; CHECK-NEXT: br label [[BB23:%.*]]
42 ; CHECK-NEXT: br label [[BB23]]
45 %i = load i64, i64* @d, align 8
46 %i1 = icmp eq i64 %i, 0
47 %i2 = load i64, i64* @a, align 8
48 %i3 = icmp ne i64 %i2, 0
49 br i1 %i1, label %bb13, label %bb4
52 %i5 = load i16, i16* %arg, align 2
53 %i6 = trunc i16 %i5 to i8
54 store i8 %i6, i8* @c, align 1
55 tail call void @llvm.assume(i1 %i3)
56 %i7 = load i16, i16* %arg, align 2
57 %i8 = trunc i16 %i7 to i8
58 store i8 %i8, i8* @c, align 1
59 %i9 = load i16, i16* %arg, align 2
60 %i10 = trunc i16 %i9 to i8
61 store i8 %i10, i8* @c, align 1
62 %i11 = load i16, i16* %arg, align 2
63 %i12 = trunc i16 %i11 to i8
64 store i8 %i12, i8* @c, align 1
68 %i14 = load i16, i16* %arg, align 2
69 %i15 = trunc i16 %i14 to i8
70 store i8 %i15, i8* @c, align 1
71 %i16 = load i16, i16* %arg, align 2
72 %i17 = trunc i16 %i16 to i8
73 store i8 %i17, i8* @c, align 1
74 %i18 = load i16, i16* %arg, align 2
75 %i19 = trunc i16 %i18 to i8
76 store i8 %i19, i8* @c, align 1
77 %i20 = load i16, i16* %arg, align 2
78 %i21 = trunc i16 %i20 to i8
79 store i8 %i21, i8* @c, align 1
82 bb22: ; preds = %bb13, %bb4
85 bb23: ; preds = %bb23, %bb22
89 ; Function Attrs: nounwind willreturn
90 declare void @llvm.assume(i1) #0
92 attributes #0 = { nounwind willreturn }