-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[ValueTracking] Remove opcode whitelist from matchSimpleRecurrence. #144031
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
[ValueTracking] Remove opcode whitelist from matchSimpleRecurrence. #144031
Conversation
Note: I'm not sure how this can be tested, but llvm#143878 is affected by this change.
@llvm/pr-subscribers-llvm-analysis Author: Ricardo Jesus (rj-jesus) ChangesNote: I'm not sure how to test this, but #143878 is affected by this change. Full diff: https://github.com/llvm/llvm-project/pull/144031.diff 1 Files Affected:
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 0a460786d00ea..a9edb02440b5e 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -9072,7 +9072,7 @@ bool llvm::matchSimpleRecurrence(const PHINode *P, BinaryOperator *&BO,
switch (Opcode) {
default:
continue;
- // TODO: Expand list -- xor, gep, uadd.sat etc.
+ // TODO: Expand list -- gep, uadd.sat etc.
case Instruction::LShr:
case Instruction::AShr:
case Instruction::Shl:
@@ -9082,7 +9082,9 @@ bool llvm::matchSimpleRecurrence(const PHINode *P, BinaryOperator *&BO,
case Instruction::URem:
case Instruction::And:
case Instruction::Or:
+ case Instruction::Xor:
case Instruction::Mul:
+ case Instruction::FAdd:
case Instruction::FMul: {
Value *LL = LU->getOperand(0);
Value *LR = LU->getOperand(1);
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we just remove the opcode white list entirely? Ultimately the caller has to decide which opcodes it supports, so I'm not sure this list inside matchSimpleRecurrence really has value.
Thanks, that makes sense to me. Removing the whitelist leads to an ICE on:
Presumably due to an unhandled opcode in This seems to sort it:
Does that look like a reasonable change? |
@rj-jesus I'd check for integer specifically instead of isSCEVable. I'd also move the getSCEV call into isBigEndianBitShift to cover both call-sites. (Generally the use of SCEV for that check seems a bit questionable, but that's unrelated to this patch). |
Note: This also fixes a latent bug in HashRecognize due to unhandled opcodes.
@nikic Thanks very much, I've made the changes you suggested, including removing the whitelist from Please let me know if you have any other suggestions or comments. :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Note: I'm not sure how to test this, but #143878 is affected by this change.