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

via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 7 10:36:23 PST 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-ir

Author: Craig Topper (topperc)

<details>
<summary>Changes</summary>

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
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();

``````````

</details>


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


More information about the llvm-commits mailing list