1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc --mtriple=loongarch32 -mattr=+d < %s | FileCheck %s
4 define i32 @lshr10_and255(i32 %a) {
5 ; CHECK-LABEL: lshr10_and255:
7 ; CHECK-NEXT: bstrpick.w $a0, $a0, 17, 10
10 %and = and i32 %shr, 255
14 define i32 @ashr20_and511(i32 %a) {
15 ; CHECK-LABEL: ashr20_and511:
17 ; CHECK-NEXT: bstrpick.w $a0, $a0, 28, 20
19 %shr = ashr i32 %a, 20
20 %and = and i32 %shr, 511
24 define i32 @zext_i16_to_i32(i16 %a) {
25 ; CHECK-LABEL: zext_i16_to_i32:
27 ; CHECK-NEXT: bstrpick.w $a0, $a0, 15, 0
29 %res = zext i16 %a to i32
33 define i32 @and8191(i32 %a) {
34 ; CHECK-LABEL: and8191:
36 ; CHECK-NEXT: bstrpick.w $a0, $a0, 12, 0
38 %and = and i32 %a, 8191
42 ;; Check that andi but not bstrpick.d is generated.
43 define i32 @and4095(i32 %a) {
44 ; CHECK-LABEL: and4095:
46 ; CHECK-NEXT: andi $a0, $a0, 4095
48 %and = and i32 %a, 4095
52 ;; (srl (and a, 0xff0), 4) => (BSTRPICK a, 11, 4)
53 define i32 @and0xff0_lshr4(i32 %a) {
54 ; CHECK-LABEL: and0xff0_lshr4:
56 ; CHECK-NEXT: bstrpick.w $a0, $a0, 11, 4
58 %and = and i32 %a, 4080
59 %shr = lshr i32 %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 i32 @and4080_ashr5(i32 %a) {
67 ; CHECK-LABEL: and4080_ashr5:
69 ; CHECK-NEXT: bstrpick.w $a0, $a0, 11, 5
71 %and = and i32 %a, 4080
72 %shr = ashr i32 %and, 5
76 ;; Negative test: the second operand of AND is not a shifted mask
77 define i32 @and0xf30_lshr4(i32 %a) {
78 ; CHECK-LABEL: and0xf30_lshr4:
80 ; CHECK-NEXT: andi $a0, $a0, 3888
81 ; CHECK-NEXT: srli.w $a0, $a0, 4
83 %and = and i32 %a, 3888
84 %shr = lshr i32 %and, 4
88 ;; Negative test: Shamt < MaskIdx
89 define i32 @and0xff0_lshr3(i32 %a) {
90 ; CHECK-LABEL: and0xff0_lshr3:
92 ; CHECK-NEXT: andi $a0, $a0, 4080
93 ; CHECK-NEXT: srli.w $a0, $a0, 3
95 %and = and i32 %a, 4080
96 %shr = lshr i32 %and, 3