We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 367e689 commit 9b10191Copy full SHA for 9b10191
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -7454,6 +7454,19 @@ SDValue AArch64TargetLowering::LowerABD(SDValue Op, SelectionDAG &DAG) const {
7454
SDValue RHS = Op.getOperand(1);
7455
SDLoc DL(Op);
7456
7457
+ if (!isa<ConstantSDNode>(RHS) || !isLegalCmpImmed(RHS->getAsAPIntVal())) {
7458
+ SDValue TheLHS = isCMN(LHS, IsSigned ? ISD::SETGE : ISD::SETUGE, DAG)
7459
+ ? LHS.getOperand(1)
7460
+ : LHS;
7461
+ SDValue TheRHS = isCMN(RHS, IsSigned ? ISD::SETGE : ISD::SETUGE, DAG)
7462
+ ? RHS.getOperand(1)
7463
+ : RHS;
7464
+ if (getCmpOperandFoldingProfit(TheLHS) >
7465
+ getCmpOperandFoldingProfit(TheRHS)) {
7466
+ std::swap(LHS, RHS);
7467
+ }
7468
7469
+
7470
// If the subtract doesn't overflow then just use abs(sub())
7471
bool IsNonNegative = DAG.SignBitIsZero(LHS) && DAG.SignBitIsZero(RHS);
7472
llvm/test/CodeGen/AArch64/abds-neg.ll
@@ -72,8 +72,7 @@ define i16 @abd_ext_i16(i16 %a, i16 %b) nounwind {
72
define i16 @abd_ext_i16_i32(i16 %a, i32 %b) nounwind {
73
; CHECK-LABEL: abd_ext_i16_i32:
74
; CHECK: // %bb.0:
75
-; CHECK-NEXT: sxth w8, w0
76
-; CHECK-NEXT: subs w8, w8, w1
+; CHECK-NEXT: subs w8, w1, w0, sxth
77
; CHECK-NEXT: cneg w0, w8, ge
78
; CHECK-NEXT: ret
79
%aext = sext i16 %a to i64
llvm/test/CodeGen/AArch64/abds.ll
@@ -68,8 +68,7 @@ define i16 @abd_ext_i16(i16 %a, i16 %b) nounwind {
68
69
70
71
; CHECK-NEXT: cneg w0, w8, lt
@@ -498,10 +497,7 @@ define i64 @vector_legalized(i16 %a, i16 %b) {
498
497
499
; CHECK-NEXT: sxth w8, w0
500
; CHECK-NEXT: subs w8, w8, w1, sxth
501
-; CHECK-NEXT: addp d0, v0.2d
502
-; CHECK-NEXT: cneg w8, w8, mi
503
-; CHECK-NEXT: fmov x9, d0
504
-; CHECK-NEXT: add x0, x9, x8
+; CHECK-NEXT: cneg w0, w8, mi
505
506
%ea = sext i16 %a to i32
507
%eb = sext i16 %b to i32
llvm/test/CodeGen/AArch64/abdu-neg.ll
-; CHECK-NEXT: and w8, w0, #0xffff
+; CHECK-NEXT: subs w8, w1, w0, uxth
; CHECK-NEXT: cneg w0, w8, hs
%aext = zext i16 %a to i64
llvm/test/CodeGen/AArch64/abdu.ll
; CHECK-NEXT: cneg w0, w8, lo
@@ -363,10 +362,7 @@ define i64 @vector_legalized(i16 %a, i16 %b) {
363
362
364
; CHECK-NEXT: and w8, w0, #0xffff
365
; CHECK-NEXT: subs w8, w8, w1, uxth
366
367
368
369
370
371
%ea = zext i16 %a to i32
372
%eb = zext i16 %b to i32
0 commit comments