Skip to content

[IR] Use User::getHungOffOperands() in HungoffOperandTraits::op_begin/op_end(). NFC #74744

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
Dec 7, 2023

Conversation

topperc
Copy link
Collaborator

@topperc topperc commented Dec 7, 2023

User::getOperandList has to check the HasHungOffUses bit in Value to determine how the operand list is stored. If we're using HungoffOperandTraits we can assume how it is stored without checking the flag.

Noticed that the for loop in matchSimpleRecurrence was triggering loop unswitch when built with clang due to specializing based on how the operand list of the PHINode was stored.

This reduces the size of llc on my local Release+Asserts build by around 41K.

…/op_end(). NFC

User::getOperandList has to check the HasHungOffUses bit in
Value to determine how the opernad list is stored. If we're using
HungoffOperandTraits we can assume how it is stored without checking
the flag.

Noticed that the for loop in matchSimpleRecurrence was triggering
loop unswitch when built with clang due to specializing based on
how the operand list of the PHINode was stored.

This reduces the size my local Release+Asserts build by around 41K.
@llvmbot
Copy link
Member

llvmbot commented Dec 7, 2023

@llvm/pr-subscribers-llvm-ir

Author: Craig Topper (topperc)

Changes

User::getOperandList has to check the HasHungOffUses bit in Value to determine how the opernad list is stored. If we're using HungoffOperandTraits we can assume how it is stored without checking the flag.

Noticed that the for loop in matchSimpleRecurrence was triggering loop unswitch when built with clang due to specializing based on how the operand list of the PHINode was stored.

This reduces the size of llc on my local Release+Asserts build by around 41K.


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

1 Files Affected:

  • (modified) llvm/include/llvm/IR/OperandTraits.h (+2-2)
diff --git a/llvm/include/llvm/IR/OperandTraits.h b/llvm/include/llvm/IR/OperandTraits.h
index 979ad35019f8c..ffece6324aab0 100644
--- a/llvm/include/llvm/IR/OperandTraits.h
+++ b/llvm/include/llvm/IR/OperandTraits.h
@@ -94,10 +94,10 @@ struct VariadicOperandTraits {
 template <unsigned MINARITY = 1>
 struct HungoffOperandTraits {
   static Use *op_begin(User* U) {
-    return U->getOperandList();
+    return U->getHungOffOperands();
   }
   static Use *op_end(User* U) {
-    return U->getOperandList() + U->getNumOperands();
+    return U->getHungOffOperands() + U->getNumOperands();
   }
   static unsigned operands(const User *U) {
     return U->getNumOperands();

Copy link

github-actions bot commented Dec 7, 2023

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff 04cbfcc33ae9a1bc440d553abc73b02421cf6ad2 0eac008df5bb72428277d16dc06663846ad491bf -- llvm/include/llvm/IR/OperandTraits.h
View the diff from clang-format here.
diff --git a/llvm/include/llvm/IR/OperandTraits.h b/llvm/include/llvm/IR/OperandTraits.h
index ffece6324a..50e96061b6 100644
--- a/llvm/include/llvm/IR/OperandTraits.h
+++ b/llvm/include/llvm/IR/OperandTraits.h
@@ -93,9 +93,7 @@ struct VariadicOperandTraits {
 
 template <unsigned MINARITY = 1>
 struct HungoffOperandTraits {
-  static Use *op_begin(User* U) {
-    return U->getHungOffOperands();
-  }
+  static Use *op_begin(User *U) { return U->getHungOffOperands(); }
   static Use *op_end(User* U) {
     return U->getHungOffOperands() + U->getNumOperands();
   }

Copy link
Collaborator

@preames preames left a comment

Choose a reason for hiding this comment

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

LGTM - Good find!

@topperc topperc merged commit 0928312 into llvm:main Dec 7, 2023
@topperc topperc deleted the pr/hungoffoperand branch December 7, 2023 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants