Skip to content

InstSimplify: strip bad TODO (NFC) #92754

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
May 21, 2024
Merged

Conversation

artagnon
Copy link
Contributor

@artagnon artagnon commented May 20, 2024

foldIdentityShuffles requires two sets of canceling shuffles. If there are any intervening instructions, they are feeding in the result of the first set of shuffles. To eliminate the two sets of shuffles, you'd have to rewrite the head of the intervening instructions to feed in the operand of the first set of shuffles. Since modifying the IR in any way is disallowed by an analysis, strip this bad TODO.

foldIdentityShuffles() has a TODO comment about looking through
bitcasts. Looking through any intervening instructions when folding
shuffles is out-of-scope of InstructionSimplify, as the analysis is not
allowed to modify the IR in any way. Strip this bad TODO.
@artagnon artagnon requested review from arsenm and nikic May 20, 2024 13:52
@llvmbot
Copy link
Member

llvmbot commented May 20, 2024

@llvm/pr-subscribers-llvm-analysis

Author: Ramkumar Ramachandra (artagnon)

Changes

foldIdentityShuffles() has a TODO comment about looking through bitcasts. Looking through any intervening instructions when folding shuffles is out-of-scope of InstructionSimplify, as the analysis is not allowed to modify the IR in any way. Strip this bad TODO.


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

1 Files Affected:

  • (modified) llvm/lib/Analysis/InstructionSimplify.cpp (-3)
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index 37a7259a5cd02..e88736b5fab8d 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -5346,9 +5346,6 @@ static Value *foldIdentityShuffles(int DestElt, Value *Op0, Value *Op1,
         SourceShuf->getMaskValue(RootElt), RootVec, MaxRecurse);
   }
 
-  // TODO: Look through bitcasts? What if the bitcast changes the vector element
-  // size?
-
   // The source operand is not a shuffle. Initialize the root vector value for
   // this shuffle if that has not been done yet.
   if (!RootVec)

@arsenm
Copy link
Contributor

arsenm commented May 20, 2024

foldIdentityShuffles() has a TODO comment about looking through bitcasts. Looking through any intervening instructions when folding shuffles is out-of-scope of InstructionSimplify, as the analysis is not allowed to modify the IR in any way. Strip this bad TODO.

You can look through intervening instructions, you just can't introduce new instructions. You can still probably manage a restricted subset of what you were trying to do but I didn't look that closely

@artagnon
Copy link
Contributor Author

Think about it. foldIdentityShuffles() requires two sets of canceling shuffles. If there are any intervening instructions, they are feeding in the result of the first set of shuffles. To eliminate the two sets of shuffles, you'd have to rewrite the head of the intervening instructions to feed in the operand of the first set of shuffles.

Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

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

@artagnon I think the point of this TODO is something like shuffle(bitcast(shuffle()) where the whole sequence cancels out, e.g. because the inner shuffle is 3,2,1,0 and the outer is 6,7,4,5,2,3,0,1 on elements half as wide. There is no need for any IR rewrites in that case.

I'm fine with dropping it though, this kind of TODO often does more damage than good -- the worst PRs we get are from inexperienced contributors trying to resolve TODOs.

@artagnon artagnon merged commit c4d6867 into llvm:main May 21, 2024
5 of 6 checks passed
@artagnon artagnon deleted the is-todo-strip branch May 21, 2024 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants