Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
77578ba
[MergeICmps] First implementation of merging comparisons that compare…
PhilippRados Jan 30, 2025
2304207
[MergeICmps] SelectCmp checkpoint
PhilippRados Feb 14, 2025
8455691
[MergeICmps] Implemented merge with constant across basic blocks
PhilippRados Feb 16, 2025
79b1565
[MergeICmps] Use RTTI; Can merge mixed comparison chains
PhilippRados Feb 20, 2025
fdc482f
[MergeIcmps] Supports basic blocks using select insts
PhilippRados Feb 26, 2025
95ccfcc
[MergeIcmps] Only print merged bb-name once
PhilippRados Feb 26, 2025
9c2c386
[MergeIcmps] Added tests for merging const-/bce-comparisons using sel…
PhilippRados Feb 28, 2025
52e03df
[MergeIcmps] Reimplemented block-splitting for multbceblocks; fixed b…
PhilippRados Feb 28, 2025
a3005c0
[MergeICmps] Added tests for splitting const and select blocks
PhilippRados Mar 12, 2025
e3caafc
[MergeICmps] Can build const-cmp-chains of different types using llvm…
PhilippRados Mar 12, 2025
9f18a02
[MergeICmps] Changed tests to allocate structs instead of arrays for …
PhilippRados Mar 12, 2025
a4d9733
[MergeICmps] Changed tests to use packed structs
PhilippRados Mar 19, 2025
d15a2ce
[MergeICmps] Refactored how cmp-instructions are stored per block
PhilippRados Mar 21, 2025
e5d3e57
[MergeICmps] Use shared-ptr to avoid leaking memory
PhilippRados Mar 21, 2025
b5b557c
[MergeICmps] Reduced copies for mergeBlocks
PhilippRados Mar 21, 2025
31ea42e
[MergeICmps] Don't split up select blocks if they aren't merged in th…
PhilippRados Mar 22, 2025
ebf2075
[MergeICmps] Ensure cmp-chains that require splitting come first
PhilippRados Mar 22, 2025
b575654
[MergeICmps] Made instruction splicing more robust by not assuming se…
PhilippRados Mar 22, 2025
cb53e53
[MergeICmps] Cleaned up code and added new debug info
PhilippRados Mar 23, 2025
dd4cd88
[MergeICmps] Use GlobalConstant instead of local alloca for const-cmp…
PhilippRados Mar 24, 2025
e029beb
[MergerICmps] Tested that global constant is properly removed in expa…
PhilippRados Mar 31, 2025
e1fe528
[MergerICmps] Formatted
PhilippRados Mar 31, 2025
221fe35
[MergerICmps] Fixed global var removal for failing memcmp codegen tests
PhilippRados Mar 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions llvm/lib/CodeGen/ExpandMemCmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -878,9 +878,22 @@ static bool expandMemCmp(CallInst *CI, const TargetTransformInfo *TTI,
NumMemCmpInlined++;

if (Value *Res = Expansion.getMemCmpExpansion()) {
auto *GV = dyn_cast<GlobalVariable>(CI->getArgOperand(1));
// Replace call with result of expansion and erase call.
CI->replaceAllUsesWith(Res);
CI->eraseFromParent();

// If the memcmp call used a global constant to merge comparisons and
// the global constant was folded then the variable can be deleted
// since it isn't used anymore.
// This is mostly done when mergeicmps used a global constant to merge
// constant comparisons.
if (GV && GV->hasPrivateLinkage() && GV->isConstant() &&
!GV->isConstantUsed()) {
LLVM_DEBUG(dbgs() << "Removing global constant " << GV->getName()
<< " that was used by the dead memcmp() call\n");
GV->eraseFromParent();
}
}

return true;
Expand Down
Loading
Loading