Confirmed users
24
edits
No edit summary |
|||
Line 75: | Line 75: | ||
This function is used to fold common expressions into simpler or faster variants. The function returns ''this'' when it cannot get folded and the new MIR node when it can get folded. A common uses of this function is to replace MIR nodes that have constant operands and replace this node with the computed value. But it is not limited to constant folding. Specific combinations of MIR nodes can get matched and replaced by this function. | This function is used to fold common expressions into simpler or faster variants. The function returns ''this'' when it cannot get folded and the new MIR node when it can get folded. A common uses of this function is to replace MIR nodes that have constant operands and replace this node with the computed value. But it is not limited to constant folding. Specific combinations of MIR nodes can get matched and replaced by this function. | ||
There are some caveats when implementing such a function: | |||
* One needs to keep type consistent. The output type of the replacement MIR node must be the same as the replaced MIR node. | |||
* If you make an assumption on type of the operand and don't use that operand in the replacement MIR node you need to mark that the operand as "''setGuardRangeBailouts''". That will make sure we don't remove the type assumption. | |||
=== Examples === | === Examples === |