[llvm] [SelectOpt] Add handling for Select-like operations. (PR #77284)

Sotiris Apostolakis via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 16 15:02:48 PST 2024


================
@@ -378,6 +378,15 @@ class TargetTransformInfoImplBase {
 
   bool enableSelectOptimize() const { return true; }
 
+  bool shouldTreatInstructionLikeSelect(Instruction *I) {
+    // If the select is a logical-and/logical-or then it is better treated as a
+    // and/or by the backend.
+    using namespace llvm::PatternMatch;
+    return isa<SelectInst>(I) &&
----------------
sapostolakis wrote:

I would prefer this function to only consider eligibility for select like instructions (excluding SelectInst). As I said in the earlier comment, a flag should protect the select-like optis (and exclude the regular SelectInst opti that is already protected by an existing flag). 
I am okay with having SelectInst being a subset of SelectLike and unified handling but I would like to be able to turn on SelectInst-only optis and leave the other select-like optis turned off if needed.

https://github.com/llvm/llvm-project/pull/77284


More information about the llvm-commits mailing list