Instructions that produceSameValue produce same values for operands with
same index. matchEqualDefs used to return true for any two values from
different instructions that produce same values. Fix this by checking if
values are defined by operands with the same index.
Details
Diff Detail
Event Timeline
Is this a bug fix or just a missed optimization? Surely matchEqualDefs is not required to return true when two defs have the same value?
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp | ||
---|---|---|
2721 | Maybe your new code ought to go here? And maybe it should apply to any instruction with multiple return registers, not just unmerge? |
Merge the same instructions case with different instructions that produce same values.
Check for all instructions with multiple defs not only g_unmerge.
This is bug fix, matchEqualDefs always returns true when different I1 and I2 produce same values (missing operand index check).
The bug fix looks good to me. Inline comments are just about optimization.
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp | ||
---|---|---|
2671–2676 | I'm not sure if it's a good idea to remove this code.
Thoughts? | |
2741 | If findRegisterDefOperandIdx is slow then it might be worth adding a fast case like: "if I1 only has 1 def, return true". But I'm not sure if it's worth it. |
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp | ||
---|---|---|
2741 | findRegisterDefOperandIdx simply loops through operands, if it is only one def it will match it in first try. Num operands is already calculated so it is probably a little bit faster in theory but I don't think it is worth it. |
I'm not sure if it's a good idea to remove this code.
Thoughts?
Adding Stas who wrote this code.