[InstCombine] add extra-use tests for fmul+sqrt; NFC
Details
Diff Detail
Event Timeline
| llvm/test/Transforms/InstCombine/fmul-sqrt.ll | ||
|---|---|---|
| 121 | Hi Sanjay, The function "SimplifyAssociativeOrCommutative" is called before we try to fold x * 1/sqrt(x) to x/sqrt(x) in the function "visitFMul" . This function swaps the operand x *1/sqrt(x) to 1/sqrt(x) *x based on complexity values. Rule for commutative operator: LHS (more complexity value ) Binary RHS (less complexity value). --Snip-- Instruction::BinaryOps Opcode = I.getOpcode();
bool Changed = false;
// Order operands such that they are listed from right (least complex) to
// left (most complex). This puts constants before unary operators before
// binary operators.
if (I.isCommutative() && getComplexity(I.getOperand(0)) <
getComplexity(I.getOperand(1)))
Changed = !I.swapOperands();---Snip-- So looks like we don't need to match for x *1/sqrt(x) in D86726. | |
| llvm/test/Transforms/InstCombine/fmul-sqrt.ll | ||
|---|---|---|
| 121 | May be I should try a different test case for x * 1/sqrt(x) where x is an expression with same or higher complexity than 1/sqrt(x). | |
As per the comment given by Sanjay, updated the coverage test for x*1/sqrt(x) pattern.
LGTM
| llvm/test/Transforms/InstCombine/fmul-sqrt.ll | ||
|---|---|---|
| 121 | Right! Looks like you got it. Sorry if my earlier comment was not clear. I prefer to label that extra expression with a code comment (grep for "thwart" in this test directory), so other readers will have a better chance of understanding why the 'add' in this case is included in the test. | |
| llvm/test/Transforms/InstCombine/fmul-sqrt.ll | ||
|---|---|---|
| 121 | Oh!! I did not understand your earlier comment. Instead of adding "thwart", I changed the test case. Also can you please commit on behalf of me. | |
Committed here:
rG86163f885b5
Please request commit access so you're not waiting on others to push an approved patch.
This is not providing the test coverage that you intended - notice that the operands of fmul are swapped.
Please see my comment about complexity-based canonicalization in D86395.