[llvm] c100f35 - [LoongArch] Add tests for (and (add x, c1), (lshr y, c2))

Weining Lu via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 24 02:13:10 PDT 2023


Author: WANG Rui
Date: 2023-07-24T17:12:10+08:00
New Revision: c100f35f02d4556cb8b8f54864660a7eede565bb

URL: https://github.com/llvm/llvm-project/commit/c100f35f02d4556cb8b8f54864660a7eede565bb
DIFF: https://github.com/llvm/llvm-project/commit/c100f35f02d4556cb8b8f54864660a7eede565bb.diff

LOG: [LoongArch] Add tests for (and (add x, c1), (lshr y, c2))

Add tests for (and (add x, c1), (lshr y, c2)).

Signed-off-by: WANG Rui <wangrui at loongson.cn>

Reviewed By: SixWeining, xen0n

Differential Revision: https://reviews.llvm.org/D154809

Added: 
    

Modified: 
    llvm/test/CodeGen/LoongArch/ir-instruction/and.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/CodeGen/LoongArch/ir-instruction/and.ll b/llvm/test/CodeGen/LoongArch/ir-instruction/and.ll
index a038ddc450a0fd..0604edccb4fe0b 100644
--- a/llvm/test/CodeGen/LoongArch/ir-instruction/and.ll
+++ b/llvm/test/CodeGen/LoongArch/ir-instruction/and.ll
@@ -424,3 +424,25 @@ define i64 @and_i64_0xfff0_multiple_times(i64 %a, i64 %b, i64 %c) {
   %i = xor i64 %g, %h
   ret i64 %i
 }
+
+define i32 @and_add_lsr(i32 %x, i32 %y) {
+; LA32-LABEL: and_add_lsr:
+; LA32:       # %bb.0:
+; LA32-NEXT:    ori $a2, $zero, 4095
+; LA32-NEXT:    add.w $a0, $a0, $a2
+; LA32-NEXT:    srli.w $a1, $a1, 20
+; LA32-NEXT:    and $a0, $a1, $a0
+; LA32-NEXT:    ret
+;
+; LA64-LABEL: and_add_lsr:
+; LA64:       # %bb.0:
+; LA64-NEXT:    ori $a2, $zero, 4095
+; LA64-NEXT:    add.d $a0, $a0, $a2
+; LA64-NEXT:    bstrpick.d $a1, $a1, 31, 20
+; LA64-NEXT:    and $a0, $a1, $a0
+; LA64-NEXT:    ret
+  %1 = add i32 %x, 4095
+  %2 = lshr i32 %y, 20
+  %r = and i32 %2, %1
+  ret i32 %r
+}


        


More information about the llvm-commits mailing list