diff --git a/llvm/test/CodeGen/AArch64/addsub.ll b/llvm/test/CodeGen/AArch64/addsub.ll index ba7edaf8f6313..33302f09ccdf7 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,89 +735,7 @@ define i32 @commute_subop0_ashr(i32 %x, i32 %y, i32 %z) { ret i32 %add } -; ((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, #222 -; CHECK-NEXT: mov w9, #111 -; CHECK-NEXT: mul w8, w1, w8 -; CHECK-NEXT: neg w8, w8 -; CHECK-NEXT: madd w8, w0, w9, w8 -; CHECK-NEXT: add w8, w8, w2 -; CHECK-NEXT: add w0, w8, w8, lsl #5 -; CHECK-NEXT: ret - %aa = mul i16 %a, 111 - %bb = mul 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 = mul i8 %trunc, 33 - 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) +; 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: @@ -830,7 +748,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: @@ -842,7 +760,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: @@ -857,7 +775,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: