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

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


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc100f35f02d4: [LoongArch] Add tests for (and (add x, c1), (lshr y, c2)) (authored by hev, committed by SixWeining).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154809/new/

https://reviews.llvm.org/D154809

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


Index: llvm/test/CodeGen/LoongArch/ir-instruction/and.ll
===================================================================
--- llvm/test/CodeGen/LoongArch/ir-instruction/and.ll
+++ llvm/test/CodeGen/LoongArch/ir-instruction/and.ll
@@ -424,3 +424,25 @@
   %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
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154809.543426.patch
Type: text/x-patch
Size: 879 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230724/3485fcee/attachment.bin>


More information about the llvm-commits mailing list