[PATCH] D98704: [AArch64] Rewrite (add, csel) to cinc

Sjoerd Meijer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 17 09:29:38 PDT 2021


SjoerdMeijer added a comment.

This now generates cinc, which is even better.



================
Comment at: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:13150
 
+  // If both operands are a SET_CC, then we don't want to perform this
+  // folding and create another csel as this results in more instructions
----------------
I had to keep this, otherwise this lowering will happen first and the pattern, see below, doesn't match,.


================
Comment at: llvm/lib/Target/AArch64/AArch64InstrInfo.td:2162
+          (CSINCWr GPR32:$val, GPR32:$val, (i32 imm:$cc))>;
+def : Pat<(add GPR64:$val, (zext (AArch64csel (i32 0), (i32 1), (i32 imm:$cc), NZCV))),
+          (CSINCXr GPR64:$val, GPR64:$val, (i32 imm:$cc))>;
----------------
I had to add an `zext` for this pattern, that's because the way `setcc` is legalised from an i1 to i32 first, then zext'ed to i64.


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

https://reviews.llvm.org/D98704



More information about the llvm-commits mailing list