[llvm] [InstCombine] Enable select freeze poison folding when storing value (PR #129776)
John McIver via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 8 21:27:38 PST 2025
================
@@ -4812,7 +4812,14 @@ Instruction *InstCombinerImpl::visitFreeze(FreezeInst &I) {
//
// TODO: This could use getBinopAbsorber() / getBinopIdentity() to avoid
// duplicating logic for binops at least.
- auto getUndefReplacement = [&I](Type *Ty) {
+ auto getUndefReplacement = [&I, &AC = this->AC,
+ &DT = this->DT](Type *Ty) -> Value * {
+ Value *SelectArgument = nullptr;
+ if (match(&I, m_OneUse(m_Freeze(m_Poison()))) &&
+ match(I.user_back(),
+ m_c_Select(m_Specific(&I), m_Value(SelectArgument))) &&
+ isGuaranteedNotToBeUndefOrPoison(SelectArgument, &AC, &I, &DT))
+ return SelectArgument;
----------------
jmciver wrote:
The transformation was based on a single use of freeze poison so we hoisted it out of the use analysis loop.
To verify we would want to be able to do something like the following?
https://alive2.llvm.org/ce/z/pyGVuw
https://github.com/llvm/llvm-project/pull/129776
More information about the llvm-commits
mailing list