The following changes are necessary to get the generated tree matcher to compile:
- In CodeExpansions::declare(), the assert() prevents connecting two instructions. E.g. the match code (match (MUL $t, $s1, $s2), (SUB $d, $t, $s3)), results in two declarations of $t, one for the def and one for the use. Removing the assertion allows this construct. If $t is later used, it is one of the operands, which should be perfectly fine for now.
- The code emitted in GIMatchTreeVRegDefPartitioner::generatePartitionSelectorCode() is not compilable:
- The value of NewInstrID should be emitted, not the name
- Both calls involving getOperand() end with one parenthesis too many
- Swaps generated condition for the partition code in the latter function
- The code emitted in GIMatchTreeVRegDefPartitioner::generatePartitionSelectorCode() is not compilable:
With these changes it is possible to use linear patterns.
I also change the rules i2p_to_p2i, fabs_fabs_fold, and fneg_fneg_fold
to use the tree matcher for a linear match. These rules are tested by:
CodeGen/AArch64/GlobalISel/combine-fabs.mir
CodeGen/AArch64/GlobalISel/combine-fneg.mir
CodeGen/AArch64/GlobalISel/combine-ptrtoint.mir
CodeGen/AMDGPU/GlobalISel/combine-add-nullptr.mir
Should also delete matchCombineFNegOfFNeg