xref: /aosp_15_r20/external/llvm/test/CodeGen/Hexagon/cmp-promote.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=hexagon < %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker;
3*9880d681SAndroid Build Coastguard Worker; Bug 6714. Use sign-extend to promote the arguments for compare
4*9880d681SAndroid Build Coastguard Worker; equal/not-equal for 8- and 16-bit types with negative constants.
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Worker; CHECK: cmp.eq{{.*}}#-16
7*9880d681SAndroid Build Coastguard Workerdefine i32 @foo1(i16 signext %q) nounwind readnone {
8*9880d681SAndroid Build Coastguard Workerentry:
9*9880d681SAndroid Build Coastguard Worker  %not.cmp = icmp ne i16 %q, -16
10*9880d681SAndroid Build Coastguard Worker  %res.0 = zext i1 %not.cmp to i32
11*9880d681SAndroid Build Coastguard Worker  ret i32 %res.0
12*9880d681SAndroid Build Coastguard Worker}
13*9880d681SAndroid Build Coastguard Worker
14*9880d681SAndroid Build Coastguard Worker; CHECK: cmp.eq{{.*}}#-14
15*9880d681SAndroid Build Coastguard Workerdefine i32 @foo2(i16 signext %q) nounwind readnone {
16*9880d681SAndroid Build Coastguard Workerentry:
17*9880d681SAndroid Build Coastguard Worker  %cmp = icmp eq i16 %q, -14
18*9880d681SAndroid Build Coastguard Worker  %res.0 = select i1 %cmp, i32 2, i32 0
19*9880d681SAndroid Build Coastguard Worker  ret i32 %res.0
20*9880d681SAndroid Build Coastguard Worker}
21*9880d681SAndroid Build Coastguard Worker
22*9880d681SAndroid Build Coastguard Worker; CHECK: cmp.eq{{.*}}#-8
23*9880d681SAndroid Build Coastguard Workerdefine i32 @foo3(i8 signext %r) nounwind readnone {
24*9880d681SAndroid Build Coastguard Workerentry:
25*9880d681SAndroid Build Coastguard Worker  %cmp = icmp eq i8 %r, -8
26*9880d681SAndroid Build Coastguard Worker  %res.0 = select i1 %cmp, i32 0, i32 3
27*9880d681SAndroid Build Coastguard Worker  ret i32 %res.0
28*9880d681SAndroid Build Coastguard Worker}
29*9880d681SAndroid Build Coastguard Worker
30*9880d681SAndroid Build Coastguard Worker; CHECK: cmp.eq{{.*}}#-6
31*9880d681SAndroid Build Coastguard Workerdefine i32 @foo4(i8 signext %r) nounwind readnone {
32*9880d681SAndroid Build Coastguard Workerentry:
33*9880d681SAndroid Build Coastguard Worker  %cmp = icmp eq i8 %r, -6
34*9880d681SAndroid Build Coastguard Worker  %res.0 = select i1 %cmp, i32 4, i32 0
35*9880d681SAndroid Build Coastguard Worker  ret i32 %res.0
36*9880d681SAndroid Build Coastguard Worker}
37*9880d681SAndroid Build Coastguard Worker
38*9880d681SAndroid Build Coastguard Worker; CHECK: cmp.eq{{.*}}#-20
39*9880d681SAndroid Build Coastguard Workerdefine i32 @foo5(i32 %s) nounwind readnone {
40*9880d681SAndroid Build Coastguard Workerentry:
41*9880d681SAndroid Build Coastguard Worker  %cmp = icmp eq i32 %s, -20
42*9880d681SAndroid Build Coastguard Worker  %res.0 = select i1 %cmp, i32 0, i32 5
43*9880d681SAndroid Build Coastguard Worker  ret i32 %res.0
44*9880d681SAndroid Build Coastguard Worker}
45*9880d681SAndroid Build Coastguard Worker
46*9880d681SAndroid Build Coastguard Worker; CHECK: cmp.eq{{.*}}#-18
47*9880d681SAndroid Build Coastguard Workerdefine i32 @foo6(i32 %s) nounwind readnone {
48*9880d681SAndroid Build Coastguard Workerentry:
49*9880d681SAndroid Build Coastguard Worker  %cmp = icmp eq i32 %s, -18
50*9880d681SAndroid Build Coastguard Worker  %res.0 = select i1 %cmp, i32 6, i32 0
51*9880d681SAndroid Build Coastguard Worker  ret i32 %res.0
52*9880d681SAndroid Build Coastguard Worker}
53*9880d681SAndroid Build Coastguard Worker
54*9880d681SAndroid Build Coastguard Worker; CHECK: cmp.eq{{.*}}#10
55*9880d681SAndroid Build Coastguard Workerdefine i32 @foo7(i16 signext %q) nounwind readnone {
56*9880d681SAndroid Build Coastguard Workerentry:
57*9880d681SAndroid Build Coastguard Worker  %cmp = icmp eq i16 %q, 10
58*9880d681SAndroid Build Coastguard Worker  %res.0 = select i1 %cmp, i32 7, i32 0
59*9880d681SAndroid Build Coastguard Worker  ret i32 %res.0
60*9880d681SAndroid Build Coastguard Worker}
61*9880d681SAndroid Build Coastguard Worker
62*9880d681SAndroid Build Coastguard Worker@g = external global i16
63*9880d681SAndroid Build Coastguard Worker
64*9880d681SAndroid Build Coastguard Worker; CHECK: cmp.eq{{.*}}#-12
65*9880d681SAndroid Build Coastguard Workerdefine i32 @foo8() nounwind readonly {
66*9880d681SAndroid Build Coastguard Workerentry:
67*9880d681SAndroid Build Coastguard Worker  %0 = load i16, i16* @g, align 2
68*9880d681SAndroid Build Coastguard Worker  %cmp = icmp eq i16 %0, -12
69*9880d681SAndroid Build Coastguard Worker  %res.0 = select i1 %cmp, i32 0, i32 8
70*9880d681SAndroid Build Coastguard Worker  ret i32 %res.0
71*9880d681SAndroid Build Coastguard Worker}
72*9880d681SAndroid Build Coastguard Worker
73