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

David Green via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 16 07:19:54 PST 2024


================
@@ -412,6 +412,16 @@ class AArch64TTIImpl : public BasicTTIImplBase<AArch64TTIImpl> {
 
   bool enableSelectOptimize() { return ST->enableSelectOptimize(); }
 
+  bool shouldTreatInstructionLikeSelect(Instruction *I) {
+    // For the binary operators (e.g. or) we need to be more careful than
+    // selects, here we only transform them if they are already at a natural
+    // break point in the code - the end of a block with an unconditional
+    // terminator.
+    return isa<SelectInst>(I) ||
+           (isa<BinaryOperator>(I) && isa<BranchInst>(I->getNextNode()) &&
----------------
davemgreen wrote:

Yep. There will always be at least a terminator at the end of the block.

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


More information about the llvm-commits mailing list