[llvm] [IVDescriptors][NFC] Refactor getReductionOpChain to remove the dependency of non-arithmetic reductions on getOpcode. (PR #118777)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 9 06:57:12 PST 2024


================
@@ -1081,15 +1086,15 @@ RecurrenceDescriptor::getReductionOpChain(PHINode *Phi, Loop *L) const {
   // more expensive than out-of-loop reductions, and need to be costed more
   // carefully.
   unsigned ExpectedUses = 1;
-  if (RedOp == Instruction::ICmp || RedOp == Instruction::FCmp)
+  if (IsNonArithmetic)
----------------
david-arm wrote:

I'm not sure this patch is really NFC because in theory `IsNonArithmetic` could be true when Kind is RecurKind::None. Also, even if you remove references to `getOpcode` for AnyOf recurrence kinds in this function there are still lots of places in LoopVectorize.cpp that call RecurrenceDescriptor::getOpcode(). It's not obvious to me right now that you can avoid calling `getOpcode` for AnyOf types. Also, if you have to specialise the code everywhere to avoid calling `getOpcode` for AnyOf kinds wouldn't that make the code even more complicated?

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


More information about the llvm-commits mailing list