Skip to content

Commit 5fb2002

Browse files
authored
[Mips] Add test for AND optimization (#102278)
See #42826
1 parent 863a2ed commit 5fb2002

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
; RUN: llc < %s -mtriple=mips64el-unknown-linux-gnu -mcpu=mips64 | FileCheck %s \
2+
; RUN: -check-prefix=MIPS4
3+
; RUN: llc < %s -mtriple=mips64el-unknown-linux-gnu -mcpu=mips64r2 | FileCheck %s \
4+
; RUN: -check-prefix=MIPS64R2
5+
6+
define i64 @foo(i64 noundef %a) {
7+
; MIPS4-LABEL: foo:
8+
; MIPS4: # %bb.0: # %entry
9+
; MIPS4-NEXT: sll $1, $4, 0
10+
; MIPS4-NEXT: srl $1, $1, 2
11+
; MIPS4-NEXT: andi $1, $1, 7
12+
; MIPS4-NEXT: daddiu $2, $zero, 1
13+
; MIPS4-NEXT: jr $ra
14+
; MIPS4-NEXT: dsllv $2, $2, $1
15+
;
16+
; MIPS64R2-LABEL: foo:
17+
; MIPS64R2: # %bb.0: # %entry
18+
; MIPS64R2-NEXT: sll $1, $4, 0
19+
; MIPS64R2-NEXT: ext $1, $1, 2, 3
20+
; MIPS64R2-NEXT: daddiu $2, $zero, 1
21+
; MIPS64R2-NEXT: jr $ra
22+
; MIPS64R2-NEXT: dsllv $2, $2, $1
23+
entry:
24+
%div1 = lshr i64 %a, 2
25+
%and = and i64 %div1, 7
26+
%shl = shl nuw nsw i64 1, %and
27+
ret i64 %shl
28+
}

0 commit comments

Comments
 (0)