[PATCH] D154818: [LoongArch] Add test case showing suboptimal codegen when loading unsigned char/short
Lu Weining via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 24 02:50:05 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG90e08c260060: [LoongArch] Add test case showing suboptimal codegen when loading unsigned… (authored by hev, committed by SixWeining).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D154818/new/
https://reviews.llvm.org/D154818
Files:
llvm/test/CodeGen/LoongArch/zext-with-load-is-free.ll
Index: llvm/test/CodeGen/LoongArch/zext-with-load-is-free.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/LoongArch/zext-with-load-is-free.ll
@@ -0,0 +1,44 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 3
+; RUN: llc --mtriple=loongarch32 -verify-machineinstrs < %s \
+; RUN: | FileCheck %s --check-prefix=LA32
+; RUN: llc --mtriple=loongarch64 -verify-machineinstrs < %s \
+; RUN: | FileCheck %s --check-prefix=LA64
+
+define zeroext i8 @test_zext_i8(ptr %p) nounwind {
+; LA32-LABEL: test_zext_i8:
+; LA32: # %bb.0:
+; LA32-NEXT: ld.b $a0, $a0, 0
+; LA32-NEXT: andi $a0, $a0, 255
+; LA32-NEXT: ret
+;
+; LA64-LABEL: test_zext_i8:
+; LA64: # %bb.0:
+; LA64-NEXT: ld.b $a0, $a0, 0
+; LA64-NEXT: andi $a0, $a0, 255
+; LA64-NEXT: ret
+ %a = load i8, ptr %p, align 1
+ br label %exit
+exit:
+ ret i8 %a
+}
+
+define zeroext i16 @test_zext_i16(ptr %p) nounwind {
+; LA32-LABEL: test_zext_i16:
+; LA32: # %bb.0:
+; LA32-NEXT: ld.bu $a1, $a0, 0
+; LA32-NEXT: ld.b $a0, $a0, 1
+; LA32-NEXT: slli.w $a0, $a0, 8
+; LA32-NEXT: or $a0, $a0, $a1
+; LA32-NEXT: bstrpick.w $a0, $a0, 15, 0
+; LA32-NEXT: ret
+;
+; LA64-LABEL: test_zext_i16:
+; LA64: # %bb.0:
+; LA64-NEXT: ld.h $a0, $a0, 0
+; LA64-NEXT: bstrpick.d $a0, $a0, 15, 0
+; LA64-NEXT: ret
+ %a = load i16, ptr %p, align 1
+ br label %exit
+exit:
+ ret i16 %a
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154818.543438.patch
Type: text/x-patch
Size: 1500 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230724/969ea92c/attachment.bin>
More information about the llvm-commits
mailing list