[InstCombine] add extra-use tests for fmul+sqrt; NFC
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).
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();
So looks like we don't need to match for x *1/sqrt(x) in D86726.
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.