[llvm] 000588d - [AArch64] Precommit test for D137069; NFC

via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 8 23:38:22 PST 2022


Author: chenglin.bi
Date: 2022-11-09T15:36:47+08:00
New Revision: 000588d9c4c015ae4c9abe778ab54903c299eebb

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

LOG: [AArch64] Precommit test for D137069; NFC

Added: 
    

Modified: 
    llvm/test/CodeGen/AArch64/addsub.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/CodeGen/AArch64/addsub.ll b/llvm/test/CodeGen/AArch64/addsub.ll
index 33302f09ccdf..4210cc5193bc 100644
--- a/llvm/test/CodeGen/AArch64/addsub.ll
+++ b/llvm/test/CodeGen/AArch64/addsub.ll
@@ -694,7 +694,7 @@ if.end:                                           ; preds = %if.then, %lor.lhs.f
   ret i32 undef
 }
 
-; ((X >> C) - Y) + Z --> (Z - Y) + (X >> C)
+; ((X << C) - Y) + Z --> (Z - Y) + (X << C)
 define i32 @commute_subop0(i32 %x, i32 %y, i32 %z) {
 ; CHECK-LABEL: commute_subop0:
 ; CHECK:       // %bb.0:
@@ -707,7 +707,7 @@ define i32 @commute_subop0(i32 %x, i32 %y, i32 %z) {
   ret i32 %add
 }
 
-; ((X << C) - Y) + Z --> (Z - Y) + (X << C)
+; ((X >> C) - Y) + Z --> (Z - Y) + (X >> C)
 define i32 @commute_subop0_lshr(i32 %x, i32 %y, i32 %z) {
 ; CHECK-LABEL: commute_subop0_lshr:
 ; CHECK:       // %bb.0:
@@ -721,7 +721,7 @@ define i32 @commute_subop0_lshr(i32 %x, i32 %y, i32 %z) {
   ret i32 %add
 }
 
-; ((X << C) - Y) + Z --> (Z - Y) + (X << C)
+; ((X >> C) - Y) + Z --> (Z - Y) + (X >> C)
 define i32 @commute_subop0_ashr(i32 %x, i32 %y, i32 %z) {
 ; CHECK-LABEL: commute_subop0_ashr:
 ; CHECK:       // %bb.0:
@@ -735,7 +735,88 @@ define i32 @commute_subop0_ashr(i32 %x, i32 %y, i32 %z) {
   ret i32 %add
 }
 
-; Z + ((X >> C) - Y) --> (Z - Y) + (X >> C)
+; ((sext X) - Y) + Z --> (Z - Y) + (sext X)
+define i64 @commute_subop0_sext(i32 %x, i64 %y, i64 %z) {
+; CHECK-LABEL: commute_subop0_sext:
+; CHECK:       // %bb.0:
+; CHECK-NEXT:    // kill: def $w0 killed $w0 def $x0
+; CHECK-NEXT:    sxtw x8, w0
+; CHECK-NEXT:    sub x8, x8, x1
+; CHECK-NEXT:    add x0, x8, x2
+; CHECK-NEXT:    ret
+  %sext = sext i32 %x to i64
+  %sub = sub i64 %sext, %y
+  %add = add i64 %sub, %z
+  ret i64 %add
+}
+
+; ((sext_inreg X) - Y) + Z --> (Z - Y) + (sext_inreg X)
+define i64 @commute_subop0_sext_inreg(i64 %x, i64 %y, i64 %z) {
+; CHECK-LABEL: commute_subop0_sext_inreg:
+; CHECK:       // %bb.0:
+; CHECK-NEXT:    sxth x8, w0
+; CHECK-NEXT:    sub x8, x8, x1
+; CHECK-NEXT:    add x0, x8, x2
+; CHECK-NEXT:    ret
+  %shl = shl i64 %x, 48
+  %ashr = ashr i64 %shl, 48
+  %sub = sub i64 %ashr, %y
+  %add = add i64 %sub, %z
+  ret i64 %add
+}
+
+; ((zext X) - Y) + Z --> (Z - Y) + (zext X)
+define i32 @commute_subop0_zext(i16 %x, i32 %y, i32 %z) {
+; CHECK-LABEL: commute_subop0_zext:
+; CHECK:       // %bb.0:
+; CHECK-NEXT:    and w8, w0, #0xffff
+; CHECK-NEXT:    sub w8, w8, w1
+; CHECK-NEXT:    add w0, w8, w2
+; CHECK-NEXT:    ret
+  %zext = zext i16 %x to i32
+  %sub = sub i32 %zext, %y
+  %add = add i32 %sub, %z
+  ret i32 %add
+}
+
+
+; ((anyext X) - Y) + Z --> (Z - Y) + (anyext X)
+define i8 @commute_subop0_anyext(i16 %a, i16 %b, i32 %c) {
+; CHECK-LABEL: commute_subop0_anyext:
+; CHECK:       // %bb.0:
+; CHECK-NEXT:    mov w8, #111
+; CHECK-NEXT:    neg w9, w1
+; CHECK-NEXT:    madd w8, w0, w8, w9
+; CHECK-NEXT:    add w8, w8, w2
+; CHECK-NEXT:    lsl w8, w8, #3
+; CHECK-NEXT:    sub w0, w8, #1776
+; CHECK-NEXT:    ret
+  %aa = mul i16 %a, 111
+  %bb = add i16 %b, 222
+  %a_32 = zext i16 %aa to i32
+  %b_32 = zext i16 %bb to i32
+  %sub = sub i32 %a_32, %b_32
+  %add = add i32 %sub, %c
+  %trunc = trunc i32 %add to i8
+  %r = shl i8 %trunc, 3
+  ret i8 %r
+}
+
+; ((X and C) - Y) + Z --> (Z - Y) + (X and C)
+define i32 @commute_subop0_and(i32 %x, i32 %y, i32 %z) {
+; CHECK-LABEL: commute_subop0_and:
+; CHECK:       // %bb.0:
+; CHECK-NEXT:    and w8, w0, #0xff
+; CHECK-NEXT:    sub w8, w8, w1
+; CHECK-NEXT:    add w0, w8, w2
+; CHECK-NEXT:    ret
+  %and = and i32 %x, 255
+  %sub = sub i32 %and, %y
+  %add = add i32 %sub, %z
+  ret i32 %add
+}
+
+; Z + ((X << C) - Y) --> (Z - Y) + (X << C)
 define i32 @commute_subop0_cadd(i32 %x, i32 %y, i32 %z) {
 ; CHECK-LABEL: commute_subop0_cadd:
 ; CHECK:       // %bb.0:
@@ -748,7 +829,7 @@ define i32 @commute_subop0_cadd(i32 %x, i32 %y, i32 %z) {
   ret i32 %add
 }
 
-; Y + ((X >> C) - X) --> (Y - X) + (X >> C)
+; Y + ((X << C) - X) --> (Y - X) + (X << C)
 define i32 @commute_subop0_mul(i32 %x, i32 %y) {
 ; CHECK-LABEL: commute_subop0_mul:
 ; CHECK:       // %bb.0:
@@ -760,7 +841,7 @@ define i32 @commute_subop0_mul(i32 %x, i32 %y) {
   ret i32 %add
 }
 
-; negative case for ((X >> C) - Y) + Z --> (Z - Y) + (X >> C)
+; negative case for ((X << C) - Y) + Z --> (Z - Y) + (X << C)
 ; Y can't be constant to avoid dead loop
 define i32 @commute_subop0_zconst(i32 %x, i32 %y) {
 ; CHECK-LABEL: commute_subop0_zconst:
@@ -775,7 +856,7 @@ define i32 @commute_subop0_zconst(i32 %x, i32 %y) {
   ret i32 %add
 }
 
-; negative case for ((X >> C) - Y) + Z --> (Z - Y) + (X >> C)
+; negative case for ((X << C) - Y) + Z --> (Z - Y) + (X << C)
 ; Y can't be shift C also to avoid dead loop
 define i32 @commute_subop0_zshiftc_oneuse(i32 %x, i32 %y, i32 %z) {
 ; CHECK-LABEL: commute_subop0_zshiftc_oneuse:


        


More information about the llvm-commits mailing list