1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
2 ; RUN: llc -mtriple=riscv64 < %s | FileCheck %s
4 define i64 @fold_binop_into_select_0(i1 %c, i64 %x) {
5 ; CHECK-LABEL: fold_binop_into_select_0:
6 ; CHECK: # %bb.0: # %entry
7 ; CHECK-NEXT: addi a1, a1, -2
8 ; CHECK-NEXT: slli a0, a0, 63
9 ; CHECK-NEXT: srai a0, a0, 63
10 ; CHECK-NEXT: and a0, a0, a1
13 %select_ = select i1 %c, i64 %x, i64 2
14 %res = sub i64 %select_, 2
18 define i64 @fold_binop_into_select_1(i1 %c, i64 %x) {
19 ; CHECK-LABEL: fold_binop_into_select_1:
20 ; CHECK: # %bb.0: # %entry
21 ; CHECK-NEXT: andi a0, a0, 1
22 ; CHECK-NEXT: addi a1, a1, -2
23 ; CHECK-NEXT: addi a0, a0, -1
24 ; CHECK-NEXT: and a0, a0, a1
27 %select_ = select i1 %c, i64 2, i64 %x
28 %res = sub i64 %select_, 2
32 define i64 @fold_binop_into_select_2(i1 %c, i64 %x) {
33 ; CHECK-LABEL: fold_binop_into_select_2:
34 ; CHECK: # %bb.0: # %entry
35 ; CHECK-NEXT: li a2, 2
36 ; CHECK-NEXT: sub a2, a2, a1
37 ; CHECK-NEXT: slli a0, a0, 63
38 ; CHECK-NEXT: srai a0, a0, 63
39 ; CHECK-NEXT: and a0, a0, a2
42 %select_ = select i1 %c, i64 %x, i64 2
43 %res = sub i64 2, %select_
47 define i64 @fold_binop_into_select_3(i1 %c, i64 %x) {
48 ; CHECK-LABEL: fold_binop_into_select_3:
49 ; CHECK: # %bb.0: # %entry
50 ; CHECK-NEXT: andi a0, a0, 1
51 ; CHECK-NEXT: li a2, 2
52 ; CHECK-NEXT: sub a2, a2, a1
53 ; CHECK-NEXT: addi a0, a0, -1
54 ; CHECK-NEXT: and a0, a0, a2
57 %select_ = select i1 %c, i64 2, i64 %x
58 %res = sub i64 2, %select_