[llvm] IVDesc: unify RecurKinds IAnyOf and FAnyOf (PR #118393)

Mel Chen via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 16 03:26:23 PST 2025


Mel-Chen wrote:

@artagnon 
Sorry, I had to use strong way to prevent the merge of this patch because I was out of the office yesterday and couldn't respond.

The purpose of this PR is really good, and I think it should continue, but my concern is that the approach and results are incorrect. 

I believe the real reason we cannot unify IAnyOf and FAnyOf is due to `getOpcode()`. In vectorizer, there are still many cases where `getOpcode()` is called unnecessarily, even though the execution path should not require it. Generally, `getOpcode()` should only have a meaningful effect for arithmetic reductions.

Earlier, I identified the locations where `getOpcode()` is currently being called: (the line numbers might be outdated because this information has been sitting in my notebook for about a month).
```
/scratch/melc/llvm-project/llvm/lib/Analysis/IVDescriptors.cpp:1066:30: #118777 
/scratch/melc/llvm-project/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp:553:37
/scratch/melc/llvm-project/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp:2133:53:
/scratch/melc/llvm-project/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp:2144:53:
/scratch/melc/llvm-project/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp:2181:78:
/scratch/melc/llvm-project/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp:2193:39:
/scratch/melc/llvm-project/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp:2231:67:
/scratch/melc/llvm-project/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp:2253:70: 
/scratch/melc/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:4874:57: preferInLoopReduction should pass kind
/scratch/melc/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:5860:27: 
/scratch/melc/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:5884:34: 
/scratch/melc/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:5922:27: 
/scratch/melc/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:5930:41: 
/scratch/melc/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7026:41: 
/scratch/melc/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:9486:57: preferPredicatedReductionSelect should pass kind
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp: 19360 [done] #122239 
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp: 20515 [look nice]
```
Because I've been busy with EVL tail folding, the cleanup may proceed slowly. Welcome your contribution If you’re willing and interested. Then we can continue this patch after we finish the clean up.  :)

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


More information about the llvm-commits mailing list