1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -O1 -S < %s | FileCheck %s
3 ; RUN: opt -passes='default<O1>' -S < %s | FileCheck %s
5 ; This is an important benchmark for color-space-conversion.
6 ; It should reduce to contain only 1 'not' op.
8 declare void @use(i8, i8, i8, i8)
10 define void @cmyk(i8 %r, i8 %g, i8 %b) {
13 ; CHECK-NEXT: [[TMP0:%.*]] = icmp sgt i8 [[R:%.*]], [[B:%.*]]
14 ; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[TMP0]], i8 [[R]], i8 [[B]]
15 ; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt i8 [[TMP1]], [[G:%.*]]
16 ; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP2]], i8 [[TMP1]], i8 [[G]]
17 ; CHECK-NEXT: [[TMP4:%.*]] = xor i8 [[TMP3]], -1
18 ; CHECK-NEXT: [[SUB31:%.*]] = sub i8 [[TMP3]], [[R]]
19 ; CHECK-NEXT: [[SUB35:%.*]] = sub i8 [[TMP3]], [[G]]
20 ; CHECK-NEXT: [[SUB39:%.*]] = sub i8 [[TMP3]], [[B]]
21 ; CHECK-NEXT: call void @use(i8 [[SUB31]], i8 [[SUB35]], i8 [[SUB39]], i8 [[TMP4]])
22 ; CHECK-NEXT: ret void
25 %conv = sext i8 %r to i32
26 %sub = sub nsw i32 255, %conv
27 %conv1 = trunc i32 %sub to i8
28 %conv2 = sext i8 %g to i32
29 %sub3 = sub nsw i32 255, %conv2
30 %conv4 = trunc i32 %sub3 to i8
31 %conv5 = sext i8 %b to i32
32 %sub6 = sub nsw i32 255, %conv5
33 %conv7 = trunc i32 %sub6 to i8
34 %conv8 = sext i8 %conv1 to i32
35 %conv9 = sext i8 %conv4 to i32
36 %cmp = icmp slt i32 %conv8, %conv9
37 br i1 %cmp, label %if.then, label %if.else
40 %conv12 = sext i8 %conv7 to i32
41 %cmp13 = icmp slt i32 %conv8, %conv12
42 %cond = select i1 %cmp13, i32 %conv8, i32 %conv12
43 %conv17 = trunc i32 %cond to i8
47 %conv19 = sext i8 %conv7 to i32
48 %cmp20 = icmp slt i32 %conv9, %conv19
49 %cond27 = select i1 %cmp20, i32 %conv9, i32 %conv19
50 %conv28 = trunc i32 %cond27 to i8
54 %k.0 = phi i8 [ %conv17, %if.then ], [ %conv28, %if.else ]
55 %conv30 = sext i8 %k.0 to i32
56 %sub31 = sub nsw i32 %conv8, %conv30
57 %conv32 = trunc i32 %sub31 to i8
58 %sub35 = sub nsw i32 %conv9, %conv30
59 %conv36 = trunc i32 %sub35 to i8
60 %conv37 = sext i8 %conv7 to i32
61 %sub39 = sub nsw i32 %conv37, %conv30
62 %conv40 = trunc i32 %sub39 to i8
63 call void @use(i8 %conv32, i8 %conv36, i8 %conv40, i8 %k.0)