Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[TTI][LV] Simplify the prototype of preferPredicatedReductionSelect. nfc #139265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 12, 2025

Conversation

Mel-Chen
Copy link
Contributor

@Mel-Chen Mel-Chen commented May 9, 2025

No description provided.

@llvmbot
Copy link
Member

llvmbot commented May 9, 2025

@llvm/pr-subscribers-backend-arm
@llvm/pr-subscribers-vectorizers
@llvm/pr-subscribers-llvm-analysis

@llvm/pr-subscribers-backend-aarch64

Author: Mel Chen (Mel-Chen)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/139265.diff

7 Files Affected:

  • (modified) llvm/include/llvm/Analysis/TargetTransformInfo.h (+1-1)
  • (modified) llvm/include/llvm/Analysis/TargetTransformInfoImpl.h (+1-4)
  • (modified) llvm/lib/Analysis/TargetTransformInfo.cpp (+2-3)
  • (modified) llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h (+1-4)
  • (modified) llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp (+1-2)
  • (modified) llvm/lib/Target/ARM/ARMTargetTransformInfo.h (+1-2)
  • (modified) llvm/lib/Transforms/Vectorize/LoopVectorize.cpp (+3-4)
diff --git a/llvm/include/llvm/Analysis/TargetTransformInfo.h b/llvm/include/llvm/Analysis/TargetTransformInfo.h
index 4e2d37be3a2b2..3f639138d8b75 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfo.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfo.h
@@ -1797,7 +1797,7 @@ class TargetTransformInfo {
   /// As opposed to the normal scheme of p = phi (0, a) which allows the select
   /// to be pulled out of the loop. If the select(.., add, ..) can be predicated
   /// by the target, this can lead to cleaner code generation.
-  bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty) const;
+  bool preferPredicatedReductionSelect() const;
 
   /// Return true if the loop vectorizer should consider vectorizing an
   /// otherwise scalar epilogue loop.
diff --git a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
index a440b6484e94d..a80b4c5179bad 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -1087,10 +1087,7 @@ class TargetTransformInfoImplBase {
   }
   virtual bool preferAlternateOpcodeVectorization() const { return true; }
 
-  virtual bool preferPredicatedReductionSelect(unsigned Opcode,
-                                               Type *Ty) const {
-    return false;
-  }
+  virtual bool preferPredicatedReductionSelect() const { return false; }
 
   virtual bool preferEpilogueVectorization() const { return true; }
 
diff --git a/llvm/lib/Analysis/TargetTransformInfo.cpp b/llvm/lib/Analysis/TargetTransformInfo.cpp
index b7e001d86e4b3..0f857399660fe 100644
--- a/llvm/lib/Analysis/TargetTransformInfo.cpp
+++ b/llvm/lib/Analysis/TargetTransformInfo.cpp
@@ -1395,9 +1395,8 @@ bool TargetTransformInfo::preferAlternateOpcodeVectorization() const {
   return TTIImpl->preferAlternateOpcodeVectorization();
 }
 
-bool TargetTransformInfo::preferPredicatedReductionSelect(unsigned Opcode,
-                                                          Type *Ty) const {
-  return TTIImpl->preferPredicatedReductionSelect(Opcode, Ty);
+bool TargetTransformInfo::preferPredicatedReductionSelect() const {
+  return TTIImpl->preferPredicatedReductionSelect();
 }
 
 bool TargetTransformInfo::preferEpilogueVectorization() const {
diff --git a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
index cefb7b97c605b..664c360032ea3 100644
--- a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
+++ b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
@@ -435,10 +435,7 @@ class AArch64TTIImpl : public BasicTTIImplBase<AArch64TTIImpl> {
   bool isLegalToVectorizeReduction(const RecurrenceDescriptor &RdxDesc,
                                    ElementCount VF) const override;
 
-  bool preferPredicatedReductionSelect(unsigned Opcode,
-                                       Type *Ty) const override {
-    return ST->hasSVE();
-  }
+  bool preferPredicatedReductionSelect() const override { return ST->hasSVE(); }
 
   InstructionCost
   getArithmeticReductionCost(unsigned Opcode, VectorType *Ty,
diff --git a/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp b/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
index 3569036de767e..6c3a1ae7e1775 100644
--- a/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
+++ b/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
@@ -2704,8 +2704,7 @@ bool ARMTTIImpl::preferInLoopReduction(RecurKind Kind, Type *Ty) const {
   }
 }
 
-bool ARMTTIImpl::preferPredicatedReductionSelect(unsigned Opcode,
-                                                 Type *Ty) const {
+bool ARMTTIImpl::preferPredicatedReductionSelect() const {
   if (!ST->hasMVEIntegerOps())
     return false;
   return true;
diff --git a/llvm/lib/Target/ARM/ARMTargetTransformInfo.h b/llvm/lib/Target/ARM/ARMTargetTransformInfo.h
index 2ce449650c3b9..20a2c59511087 100644
--- a/llvm/lib/Target/ARM/ARMTargetTransformInfo.h
+++ b/llvm/lib/Target/ARM/ARMTargetTransformInfo.h
@@ -230,8 +230,7 @@ class ARMTTIImpl : public BasicTTIImplBase<ARMTTIImpl> {
 
   bool preferInLoopReduction(RecurKind Kind, Type *Ty) const override;
 
-  bool preferPredicatedReductionSelect(unsigned Opcode,
-                                       Type *Ty) const override;
+  bool preferPredicatedReductionSelect() const override;
 
   bool shouldExpandReduction(const IntrinsicInst *II) const override {
     return false;
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 9208fc45a0188..9a303f526af2f 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -1446,13 +1446,13 @@ class LoopVectorizationCostModel {
 
   /// Returns true if the predicated reduction select should be used to set the
   /// incoming value for the reduction phi.
-  bool usePredicatedReductionSelect(unsigned Opcode, Type *PhiTy) const {
+  bool usePredicatedReductionSelect() const {
     // Force to use predicated reduction select since the EVL of the
     // second-to-last iteration might not be VF*UF.
     if (foldTailWithEVL())
       return true;
     return PreferPredicatedReductionSelect ||
-           TTI.preferPredicatedReductionSelect(Opcode, PhiTy);
+           TTI.preferPredicatedReductionSelect();
   }
 
   /// Estimate cost of an intrinsic call instruction CI if it were vectorized
@@ -9908,8 +9908,7 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
                 cast<VPInstruction>(&U)->getOpcode() ==
                     VPInstruction::ComputeFindLastIVResult);
       });
-      if (CM.usePredicatedReductionSelect(
-              PhiR->getRecurrenceDescriptor().getOpcode(), PhiTy))
+      if (CM.usePredicatedReductionSelect())
         PhiR->setOperand(1, NewExitingVPV);
     }
 

Copy link
Contributor

@fhahn fhahn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the cleanup!

@Mel-Chen Mel-Chen force-pushed the nfc-preferPredicatedReductionSelect branch from 6c2a2e0 to d1c83a3 Compare May 12, 2025 07:31
Copy link
Contributor

@david-arm david-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Mel-Chen Mel-Chen merged commit 688bccb into llvm:main May 12, 2025
11 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented May 12, 2025

LLVM Buildbot has detected a new failure on builder lldb-x86_64-debian running on lldb-x86_64-debian while building llvm at step 6 "test".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/162/builds/22187

Here is the relevant piece of the build log for the reference
Step 6 (test) failure: build (failure)
...
PASS: lldb-api :: lang/cpp/virtual-functions/TestCppVirtualFunctions.py (142 of 2912)
PASS: lldb-api :: tools/lldb-server/TestGdbRemoteSingleStep.py (143 of 2912)
PASS: lldb-api :: tools/lldb-dap/step/TestDAP_step.py (144 of 2912)
PASS: lldb-api :: functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/TestDataFormatterLibcxxStringSimulator.py (145 of 2912)
PASS: lldb-api :: functionalities/thread/num_threads/TestNumThreads.py (146 of 2912)
PASS: lldb-api :: functionalities/single-thread-step/TestSingleThreadStepTimeout.py (147 of 2912)
PASS: lldb-api :: types/TestShortType.py (148 of 2912)
PASS: lldb-api :: functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py (149 of 2912)
PASS: lldb-api :: functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py (150 of 2912)
PASS: lldb-api :: tools/lldb-dap/cancel/TestDAP_cancel.py (151 of 2912)
FAIL: lldb-api :: tools/lldb-dap/variables/children/TestDAP_variables_children.py (152 of 2912)
******************** TEST 'lldb-api :: tools/lldb-dap/variables/children/TestDAP_variables_children.py' FAILED ********************
Script:
--
/usr/bin/python3 /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/dotest.py -u CXXFLAGS -u CFLAGS --env LLVM_LIBS_DIR=/home/worker/2.0.1/lldb-x86_64-debian/build/./lib --env LLVM_INCLUDE_DIR=/home/worker/2.0.1/lldb-x86_64-debian/build/include --env LLVM_TOOLS_DIR=/home/worker/2.0.1/lldb-x86_64-debian/build/./bin --arch x86_64 --build-dir /home/worker/2.0.1/lldb-x86_64-debian/build/lldb-test-build.noindex --lldb-module-cache-dir /home/worker/2.0.1/lldb-x86_64-debian/build/lldb-test-build.noindex/module-cache-lldb/lldb-api --clang-module-cache-dir /home/worker/2.0.1/lldb-x86_64-debian/build/lldb-test-build.noindex/module-cache-clang/lldb-api --executable /home/worker/2.0.1/lldb-x86_64-debian/build/./bin/lldb --compiler /home/worker/2.0.1/lldb-x86_64-debian/build/./bin/clang --dsymutil /home/worker/2.0.1/lldb-x86_64-debian/build/./bin/dsymutil --make /usr/bin/gmake --llvm-tools-dir /home/worker/2.0.1/lldb-x86_64-debian/build/./bin --lldb-obj-root /home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb --lldb-libs-dir /home/worker/2.0.1/lldb-x86_64-debian/build/./lib -t /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/tools/lldb-dap/variables/children -p TestDAP_variables_children.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 21.0.0git (https://github.com/llvm/llvm-project.git revision 688bccb2902d5e3d665e0374691d03f6b1aeeb39)
  clang revision 688bccb2902d5e3d665e0374691d03f6b1aeeb39
  llvm revision 688bccb2902d5e3d665e0374691d03f6b1aeeb39
Skipping the following test categories: ['libc++', 'dsym', 'gmodules', 'debugserver', 'objc']
[{'$__lldb_extensions': {'declaration': {'line': 16, 'path': '/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/tools/lldb-dap/variables/children/main.cpp'}}, 'declarationLocationReference': 8, 'evaluateName': 'indexed', 'id': 4, 'indexedVariables': 1, 'memoryReference': '0x7FFF0A6E230B', 'name': 'indexed', 'type': 'Indexed', 'value': 'Indexed @ 0x7fff0a6e230b', 'variablesReference': 4}, {'$__lldb_extensions': {'declaration': {'line': 17, 'path': '/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/tools/lldb-dap/variables/children/main.cpp'}}, 'declarationLocationReference': 10, 'evaluateName': 'not_indexed', 'id': 5, 'memoryReference': '0x7FFF0A6E230A', 'name': 'not_indexed', 'type': 'NotIndexed', 'value': 'NotIndexed @ 0x7fff0a6e230a', 'variablesReference': 5}, {'$__lldb_extensions': {'declaration': {'line': 18, 'path': '/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/tools/lldb-dap/variables/children/main.cpp'}}, 'declarationLocationReference': 12, 'evaluateName': 'non_primitive_result', 'id': 6, 'memoryReference': '0x7FFF0A6E22E8', 'name': 'non_primitive_result', 'type': 'NonPrimitive', 'value': 'NonPrimitive @ 0x7fff0a6e22e8', 'variablesReference': 6}]

--
Command Output (stderr):
--
Change dir to: /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/tools/lldb-dap/variables/children
runCmd: settings clear --all

output: 

runCmd: settings set symbols.enable-external-lookup false

output: 

runCmd: settings set target.inherit-tcc true

output: 

runCmd: settings set target.disable-aslr false

output: 

runCmd: settings set target.detach-on-error false

output: 

@Mel-Chen Mel-Chen deleted the nfc-preferPredicatedReductionSelect branch May 12, 2025 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants