1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
2 ; RUN: llc < %s -mtriple=riscv64 | FileCheck %s --check-prefixes=CHECK-NOZBB
3 ; RUN: llc < %s -mtriple=riscv64 -mattr=+zbb | FileCheck %s --check-prefixes=CHECK-ZBB
5 ; This test case miscompiled for ZBB (DAGCombiner turned a SELECT into a more
6 ; poisonous AND operation).
7 define i1 @pr84653(i32 %x) {
8 ; CHECK-NOZBB-LABEL: pr84653:
9 ; CHECK-NOZBB: # %bb.0:
10 ; CHECK-NOZBB-NEXT: sext.w a1, a0
11 ; CHECK-NOZBB-NEXT: lui a2, 524288
12 ; CHECK-NOZBB-NEXT: sgtz a3, a1
13 ; CHECK-NOZBB-NEXT: addi a2, a2, -1
14 ; CHECK-NOZBB-NEXT: xor a0, a0, a2
15 ; CHECK-NOZBB-NEXT: sext.w a0, a0
16 ; CHECK-NOZBB-NEXT: slt a0, a0, a1
17 ; CHECK-NOZBB-NEXT: and a0, a3, a0
18 ; CHECK-NOZBB-NEXT: ret
20 ; CHECK-ZBB-LABEL: pr84653:
22 ; CHECK-ZBB-NEXT: sext.w a1, a0
23 ; CHECK-ZBB-NEXT: lui a2, 524288
24 ; CHECK-ZBB-NEXT: addi a2, a2, -1
25 ; CHECK-ZBB-NEXT: xor a0, a0, a2
26 ; CHECK-ZBB-NEXT: sext.w a0, a0
27 ; CHECK-ZBB-NEXT: max a0, a0, zero
28 ; CHECK-ZBB-NEXT: slt a0, a0, a1
30 %cmp1 = icmp sgt i32 %x, 0
31 %sub = sub nsw i32 2147483647, %x ; 0x7fffffff
32 %cmp2 = icmp sgt i32 %x, %sub
33 %r = select i1 %cmp1, i1 %cmp2, i1 false
37 ; This test case miscompiled for ZBB (DAGCombiner turned a SELECT into a more
38 ; poisonous AND operation).
39 define i1 @pr85190(i64 %a) {
40 ; CHECK-NOZBB-LABEL: pr85190:
41 ; CHECK-NOZBB: # %bb.0:
42 ; CHECK-NOZBB-NEXT: ori a1, a0, 7
43 ; CHECK-NOZBB-NEXT: slti a2, a0, 0
44 ; CHECK-NOZBB-NEXT: li a3, -1
45 ; CHECK-NOZBB-NEXT: slli a3, a3, 63
46 ; CHECK-NOZBB-NEXT: sub a3, a3, a1
47 ; CHECK-NOZBB-NEXT: slt a0, a0, a3
48 ; CHECK-NOZBB-NEXT: and a0, a2, a0
49 ; CHECK-NOZBB-NEXT: ret
51 ; CHECK-ZBB-LABEL: pr85190:
53 ; CHECK-ZBB-NEXT: ori a1, a0, 7
54 ; CHECK-ZBB-NEXT: li a2, -1
55 ; CHECK-ZBB-NEXT: slli a2, a2, 63
56 ; CHECK-ZBB-NEXT: sub a2, a2, a1
57 ; CHECK-ZBB-NEXT: min a1, a2, zero
58 ; CHECK-ZBB-NEXT: slt a0, a0, a1
61 %cmp1 = icmp slt i64 %a, 0
62 %sub = sub nsw i64 -9223372036854775808, %or ; 0x8000000000000000
63 %cmp2 = icmp sgt i64 %sub, %a
64 %res = select i1 %cmp1, i1 %cmp2, i1 false
68 define i1 @select_to_or(i32 %x) {
69 ; CHECK-NOZBB-LABEL: select_to_or:
70 ; CHECK-NOZBB: # %bb.0:
71 ; CHECK-NOZBB-NEXT: sext.w a1, a0
72 ; CHECK-NOZBB-NEXT: lui a2, 524288
73 ; CHECK-NOZBB-NEXT: sgtz a3, a1
74 ; CHECK-NOZBB-NEXT: addi a2, a2, -1
75 ; CHECK-NOZBB-NEXT: xor a0, a0, a2
76 ; CHECK-NOZBB-NEXT: sext.w a0, a0
77 ; CHECK-NOZBB-NEXT: slt a0, a0, a1
78 ; CHECK-NOZBB-NEXT: or a0, a3, a0
79 ; CHECK-NOZBB-NEXT: ret
81 ; CHECK-ZBB-LABEL: select_to_or:
83 ; CHECK-ZBB-NEXT: sext.w a1, a0
84 ; CHECK-ZBB-NEXT: lui a2, 524288
85 ; CHECK-ZBB-NEXT: addi a2, a2, -1
86 ; CHECK-ZBB-NEXT: xor a0, a0, a2
87 ; CHECK-ZBB-NEXT: sext.w a0, a0
88 ; CHECK-ZBB-NEXT: min a0, a0, zero
89 ; CHECK-ZBB-NEXT: slt a0, a0, a1
91 %cmp1 = icmp sgt i32 %x, 0
92 %sub = sub nsw i32 2147483647, %x ; 0x7fffffff
93 %cmp2 = icmp sgt i32 %x, %sub
94 %r = select i1 %cmp1, i1 true, i1 %cmp2