[PATCH] D30364: AArch64 : Add PreferCSEL feature.

Junmo Park via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 1 17:14:05 PST 2017


flyingforyou updated this revision to Diff 90261.
flyingforyou retitled this revision from "AArch64 : Add PreferCSEL feature for Exynos-M3." to "AArch64 : Add PreferCSEL feature.".
flyingforyou edited the summary of this revision.
flyingforyou added a comment.

After internal(Samsung only) discussion, revert patch about Exynos-M3 part.

Renato, before we add new feature for core, we use the code likes

IsExynosM1 or IsCortexA57 ...

But after discussion, we move to use Feature things instead of above code.

I am not sure that cost model can cover all the things what uArchitecture's all the specific details.


https://reviews.llvm.org/D30364

Files:
  lib/Target/AArch64/AArch64.td
  lib/Target/AArch64/AArch64InstrInfo.td
  lib/Target/AArch64/AArch64Subtarget.h


Index: lib/Target/AArch64/AArch64Subtarget.h
===================================================================
--- lib/Target/AArch64/AArch64Subtarget.h
+++ lib/Target/AArch64/AArch64Subtarget.h
@@ -76,6 +76,9 @@
   // HasZeroCycleZeroing - Has zero-cycle zeroing instructions.
   bool HasZeroCycleZeroing = false;
 
+  // If true, CSEL will be favored over CSINV or CSINC.
+  bool PreferCSEL = false;
+
   // StrictAlign - Disallow unaligned memory accesses.
   bool StrictAlign = false;
   bool UseAA = false;
@@ -179,6 +182,8 @@
 
   bool hasZeroCycleZeroing() const { return HasZeroCycleZeroing; }
 
+  bool preferCSEL() const { return PreferCSEL; }
+
   bool requiresStrictAlign() const { return StrictAlign; }
 
   bool isXRaySupported() const override { return true; }
Index: lib/Target/AArch64/AArch64InstrInfo.td
===================================================================
--- lib/Target/AArch64/AArch64InstrInfo.td
+++ lib/Target/AArch64/AArch64InstrInfo.td
@@ -43,6 +43,8 @@
 def UseAlternateSExtLoadCVTF32
     : Predicate<"Subtarget->useAlternateSExtLoadCVTF32Pattern()">;
 
+def DontUseCSEL : Predicate<"!Subtarget->preferCSEL()">;
+
 //===----------------------------------------------------------------------===//
 // AArch64-specific DAG Nodes.
 //
@@ -1133,29 +1135,29 @@
           (CSINCXr GPR64:$tval, GPR64:$fval, (i32 imm:$cc))>;
 
 def : Pat<(AArch64csel (i32 0), (i32 1), (i32 imm:$cc), NZCV),
-          (CSINCWr WZR, WZR, (i32 imm:$cc))>;
+          (CSINCWr WZR, WZR, (i32 imm:$cc))>, Requires<[DontUseCSEL]>;
 def : Pat<(AArch64csel (i64 0), (i64 1), (i32 imm:$cc), NZCV),
-          (CSINCXr XZR, XZR, (i32 imm:$cc))>;
+          (CSINCXr XZR, XZR, (i32 imm:$cc))>, Requires<[DontUseCSEL]>;
 def : Pat<(AArch64csel GPR32:$tval, (i32 1), (i32 imm:$cc), NZCV),
-          (CSINCWr GPR32:$tval, WZR, (i32 imm:$cc))>;
+          (CSINCWr GPR32:$tval, WZR, (i32 imm:$cc))>, Requires<[DontUseCSEL]>;
 def : Pat<(AArch64csel GPR64:$tval, (i64 1), (i32 imm:$cc), NZCV),
-          (CSINCXr GPR64:$tval, XZR, (i32 imm:$cc))>;
+          (CSINCXr GPR64:$tval, XZR, (i32 imm:$cc))>, Requires<[DontUseCSEL]>;
 def : Pat<(AArch64csel (i32 1), GPR32:$fval, (i32 imm:$cc), NZCV),
-          (CSINCWr GPR32:$fval, WZR, (i32 (inv_cond_XFORM imm:$cc)))>;
+          (CSINCWr GPR32:$fval, WZR, (i32 (inv_cond_XFORM imm:$cc)))>, Requires<[DontUseCSEL]>;
 def : Pat<(AArch64csel (i64 1), GPR64:$fval, (i32 imm:$cc), NZCV),
-          (CSINCXr GPR64:$fval, XZR, (i32 (inv_cond_XFORM imm:$cc)))>;
+          (CSINCXr GPR64:$fval, XZR, (i32 (inv_cond_XFORM imm:$cc)))>, Requires<[DontUseCSEL]>;
 def : Pat<(AArch64csel (i32 0), (i32 -1), (i32 imm:$cc), NZCV),
-          (CSINVWr WZR, WZR, (i32 imm:$cc))>;
+          (CSINVWr WZR, WZR, (i32 imm:$cc))>, Requires<[DontUseCSEL]>;
 def : Pat<(AArch64csel (i64 0), (i64 -1), (i32 imm:$cc), NZCV),
-          (CSINVXr XZR, XZR, (i32 imm:$cc))>;
+          (CSINVXr XZR, XZR, (i32 imm:$cc))>, Requires<[DontUseCSEL]>;
 def : Pat<(AArch64csel GPR32:$tval, (i32 -1), (i32 imm:$cc), NZCV),
-          (CSINVWr GPR32:$tval, WZR, (i32 imm:$cc))>;
+          (CSINVWr GPR32:$tval, WZR, (i32 imm:$cc))>, Requires<[DontUseCSEL]>;
 def : Pat<(AArch64csel GPR64:$tval, (i64 -1), (i32 imm:$cc), NZCV),
-          (CSINVXr GPR64:$tval, XZR, (i32 imm:$cc))>;
+          (CSINVXr GPR64:$tval, XZR, (i32 imm:$cc))>, Requires<[DontUseCSEL]>;
 def : Pat<(AArch64csel (i32 -1), GPR32:$fval, (i32 imm:$cc), NZCV),
-          (CSINVWr GPR32:$fval, WZR, (i32 (inv_cond_XFORM imm:$cc)))>;
+          (CSINVWr GPR32:$fval, WZR, (i32 (inv_cond_XFORM imm:$cc)))>, Requires<[DontUseCSEL]>;
 def : Pat<(AArch64csel (i64 -1), GPR64:$fval, (i32 imm:$cc), NZCV),
-          (CSINVXr GPR64:$fval, XZR, (i32 (inv_cond_XFORM imm:$cc)))>;
+          (CSINVXr GPR64:$fval, XZR, (i32 (inv_cond_XFORM imm:$cc)))>, Requires<[DontUseCSEL]>;
 
 // The inverse of the condition code from the alias instruction is what is used
 // in the aliased instruction. The parser all ready inverts the condition code
Index: lib/Target/AArch64/AArch64.td
===================================================================
--- lib/Target/AArch64/AArch64.td
+++ lib/Target/AArch64/AArch64.td
@@ -50,6 +50,10 @@
 def FeatureSPE : SubtargetFeature<"spe", "HasSPE", "true",
   "Enable Statistical Profiling extension">;
 
+// Some targets using CSEL is more prefer than CSINV, CSINC.
+def FeaturePreferCSEL : SubtargetFeature<"prefer-csel", "PreferCSEL",
+                                           "true", "Prefer CSEL">;
+
 /// Cyclone has register move instructions which are "free".
 def FeatureZCRegMove : SubtargetFeature<"zcm", "HasZeroCycleRegMove", "true",
                                         "Has zero-cycle register moves">;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30364.90261.patch
Type: text/x-patch
Size: 4745 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170302/e0cc32dc/attachment.bin>


More information about the llvm-commits mailing list