Skip to content

Commit 90e08c2

Browse files
heiherSixWeining
authored andcommitted
[LoongArch] Add test case showing suboptimal codegen when loading unsigned char/short
Implementing isZextFree will allow ld.bu or ld.hu to be selected rather than ld.b+mask and ld.h+mask. Signed-off-by: WANG Rui <[email protected]> Reviewed By: SixWeining, xen0n Differential Revision: https://reviews.llvm.org/D154818
1 parent 899aaff commit 90e08c2

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 3
2+
; RUN: llc --mtriple=loongarch32 -verify-machineinstrs < %s \
3+
; RUN: | FileCheck %s --check-prefix=LA32
4+
; RUN: llc --mtriple=loongarch64 -verify-machineinstrs < %s \
5+
; RUN: | FileCheck %s --check-prefix=LA64
6+
7+
define zeroext i8 @test_zext_i8(ptr %p) nounwind {
8+
; LA32-LABEL: test_zext_i8:
9+
; LA32: # %bb.0:
10+
; LA32-NEXT: ld.b $a0, $a0, 0
11+
; LA32-NEXT: andi $a0, $a0, 255
12+
; LA32-NEXT: ret
13+
;
14+
; LA64-LABEL: test_zext_i8:
15+
; LA64: # %bb.0:
16+
; LA64-NEXT: ld.b $a0, $a0, 0
17+
; LA64-NEXT: andi $a0, $a0, 255
18+
; LA64-NEXT: ret
19+
%a = load i8, ptr %p, align 1
20+
br label %exit
21+
exit:
22+
ret i8 %a
23+
}
24+
25+
define zeroext i16 @test_zext_i16(ptr %p) nounwind {
26+
; LA32-LABEL: test_zext_i16:
27+
; LA32: # %bb.0:
28+
; LA32-NEXT: ld.bu $a1, $a0, 0
29+
; LA32-NEXT: ld.b $a0, $a0, 1
30+
; LA32-NEXT: slli.w $a0, $a0, 8
31+
; LA32-NEXT: or $a0, $a0, $a1
32+
; LA32-NEXT: bstrpick.w $a0, $a0, 15, 0
33+
; LA32-NEXT: ret
34+
;
35+
; LA64-LABEL: test_zext_i16:
36+
; LA64: # %bb.0:
37+
; LA64-NEXT: ld.h $a0, $a0, 0
38+
; LA64-NEXT: bstrpick.d $a0, $a0, 15, 0
39+
; LA64-NEXT: ret
40+
%a = load i16, ptr %p, align 1
41+
br label %exit
42+
exit:
43+
ret i16 %a
44+
}

0 commit comments

Comments
 (0)