[llvm] [CodeGen] Use SmallVector for FixedStackPSVs (PR #91760)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Fri May 10 09:51:45 PDT 2024


================
@@ -122,7 +122,12 @@ const PseudoSourceValue *PseudoSourceValueManager::getJumpTable() {
 
 const PseudoSourceValue *
 PseudoSourceValueManager::getFixedStack(int FI) {
-  std::unique_ptr<FixedStackPseudoSourceValue> &V = FSValues[FI];
+  // Frame index is often continuously positive, but can be negative. Use
+  // zig-zag encoding for dense index into FSValues vector.
+  unsigned Idx = FI >= 0 ? FI << 1 : (-FI - 1) << 1 | 1;
----------------
MaskRay wrote:

Use `(2*FI) ^ (FI >> (sizeof(FI)*8-1));`? The generated code is more efficient

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


More information about the llvm-commits mailing list