[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:11 PST 2024


================
@@ -1063,7 +1068,7 @@ unsigned RecurrenceDescriptor::getOpcode(RecurKind Kind) {
 SmallVector<Instruction *, 4>
 RecurrenceDescriptor::getReductionOpChain(PHINode *Phi, Loop *L) const {
   SmallVector<Instruction *, 4> ReductionOperations;
-  unsigned RedOp = getOpcode();
+  bool IsNonArithmetic = !isArithmeticRecurrenceKind(Kind);
----------------
david-arm wrote:

I think I'd prefer this to be:

```
  bool IsComparison = Instruction::ICmp || RedOp == Instruction::FCmp;
```

or something like that. It's more precise and we don't have to worry about updating `isArithmeticRecurrenceKind` every time we add a new recurrence kind. It also explicitly excludes RecurKind::None.

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


More information about the llvm-commits mailing list