[PATCH] D132116: Precommit tests for D132115

WangLian via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 18 02:15:43 PDT 2022


Jimerlife created this revision.
Jimerlife added reviewers: RKSimon, craig.topper, sdesmalen, david-arm, benshi001.
Jimerlife added a project: LLVM.
Herald added a subscriber: StephenFan.
Herald added a project: All.
Jimerlife requested review of this revision.
Herald added subscribers: llvm-commits, jacquesguan.

Precommit tests for D132115 <https://reviews.llvm.org/D132115>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132116

Files:
  llvm/test/CodeGen/AArch64/sve-vscale-combine.ll


Index: llvm/test/CodeGen/AArch64/sve-vscale-combine.ll
===================================================================
--- llvm/test/CodeGen/AArch64/sve-vscale-combine.ll
+++ llvm/test/CodeGen/AArch64/sve-vscale-combine.ll
@@ -71,6 +71,42 @@
  ret i32 %sub
 }
 
+; Tests of multiple uses of vscale when canonicalize
+; (sub X, (vscale * C)) to (add X,  (vscale * -C))
+define i64 @multiple_uses_sub_vscale_i64(i64 %x, i64 %y) nounwind {
+; CHECK-LABEL: multiple_uses_sub_vscale_i64:
+; CHECK-NEXT:  rdvl	x8, #1
+; CHECK-NEXT:  rdvl	x9, #-1
+; CHECK-NEXT:  lsr	x8, x8, #4
+; CHECK-NEXT:  asr	x9, x9, #4
+; CHECK-NEXT:  add	x9, x0, x9
+; CHECK-NEXT:  add	x8, x1, x8
+; CHECK-NEXT:  mul	x0, x9, x8
+; CHECK-NEXT:  ret
+ %vscale = call i64 @llvm.vscale.i64()
+ %sub = sub i64 %x,  %vscale
+ %add = add i64 %y, %vscale
+ %res = mul i64 %sub, %add
+ ret i64 %res
+}
+
+define i32 @multiple_uses_sub_vscale_i32(i32 %x, i32 %y) nounwind {
+; CHECK-LABEL: multiple_uses_sub_vscale_i32:
+; CHECK-NEXT:  rdvl	x8, #1
+; CHECK-NEXT:  rdvl	x9, #-1
+; CHECK-NEXT:  lsr	x8, x8, #4
+; CHECK-NEXT:  asr	x9, x9, #4
+; CHECK-NEXT:  add	w9, w0, w9
+; CHECK-NEXT:  add	w8, w1, w8
+; CHECK-NEXT:  mul	w0, w9, w8
+; CHECK-NEXT:  ret
+ %vscale = call i32 @llvm.vscale.i32()
+ %sub = sub i32 %x, %vscale
+ %add = add i32 %y, %vscale
+ %res = mul i32 %sub, %add
+ ret i32 %res
+}
+
 ; Fold (shl (vscale * C0), C1) to (vscale * (C0 << C1)).
 ; C0 = 1 , C1 = 4
 ; At IR level,  %shl = 2^4 * VSCALE.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132116.453580.patch
Type: text/x-patch
Size: 1474 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220818/a1c35c3f/attachment.bin>


More information about the llvm-commits mailing list