1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc --mtriple=loongarch64 < %s | FileCheck %s
4 define i64 @lshr40_and255(i64 %a) {
5 ; CHECK-LABEL: lshr40_and255:
7 ; CHECK-NEXT: bstrpick.d $a0, $a0, 47, 40
10 %and = and i64 %shr, 255
14 define i64 @ashr50_and511(i64 %a) {
15 ; CHECK-LABEL: ashr50_and511:
17 ; CHECK-NEXT: bstrpick.d $a0, $a0, 58, 50
19 %shr = ashr i64 %a, 50
20 %and = and i64 %shr, 511
24 define i64 @zext_i32_to_i64(i32 %a) {
25 ; CHECK-LABEL: zext_i32_to_i64:
27 ; CHECK-NEXT: bstrpick.d $a0, $a0, 31, 0
29 %res = zext i32 %a to i64
33 define i64 @and8191(i64 %a) {
34 ; CHECK-LABEL: and8191:
36 ; CHECK-NEXT: bstrpick.d $a0, $a0, 12, 0
38 %and = and i64 %a, 8191
42 ;; Check that andi but not bstrpick.d is generated.
43 define i64 @and4095(i64 %a) {
44 ; CHECK-LABEL: and4095:
46 ; CHECK-NEXT: andi $a0, $a0, 4095
48 %and = and i64 %a, 4095
52 ;; (srl (and a, 0xff0), 4) => (BSTRPICK a, 11, 4)
53 define i64 @and0xff0_lshr4(i64 %a) {
54 ; CHECK-LABEL: and0xff0_lshr4:
56 ; CHECK-NEXT: bstrpick.d $a0, $a0, 11, 4
58 %and = and i64 %a, 4080
59 %shr = lshr i64 %and, 4
63 ;; (sra (and a, 0xff0), 5) can also be combined to (BSTRPICK a, 11, 5).
64 ;; This is because (sra (and a, 0xff0)) would be combined to (srl (and a, 0xff0), 5)
65 ;; firstly by DAGCombiner::SimplifyDemandedBits.
66 define i64 @and4080_ashr5(i64 %a) {
67 ; CHECK-LABEL: and4080_ashr5:
69 ; CHECK-NEXT: bstrpick.d $a0, $a0, 11, 5
71 %and = and i64 %a, 4080
72 %shr = ashr i64 %and, 5
76 ;; Negative test: the second operand of AND is not a shifted mask
77 define i64 @and0xf30_lshr4(i64 %a) {
78 ; CHECK-LABEL: and0xf30_lshr4:
80 ; CHECK-NEXT: andi $a0, $a0, 3888
81 ; CHECK-NEXT: srli.d $a0, $a0, 4
83 %and = and i64 %a, 3888
84 %shr = lshr i64 %and, 4
88 ;; Negative test: Shamt < MaskIdx
89 define i64 @and0xff0_lshr3(i64 %a) {
90 ; CHECK-LABEL: and0xff0_lshr3:
92 ; CHECK-NEXT: andi $a0, $a0, 4080
93 ; CHECK-NEXT: srli.d $a0, $a0, 3
95 %and = and i64 %a, 4080
96 %shr = lshr i64 %and, 3