Last active
March 4, 2024 04:58
-
-
Save RealNeGate/b2009e693739b772a69a40dd1ad50a8a to your computer and use it in GitHub Desktop.
Revisions
-
RealNeGate revised this gist
Mar 4, 2024 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,6 @@ // combined "Peeps + ConstProp + GVN" solver (extended version of the one in Combining Analyses, Combining Optimizations 7.3.2) // // returns isomorphic node (might be the same node). Node* peephole_node(Optimizer* opt, Node* n) { Node* k; bool progress = false; -
RealNeGate revised this gist
Mar 4, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ // combined "Peeps + ConstProp + GVN" solver (Combining Analyses, Combining Optimizations 7.3.2) // returns isomorphic node. Node* peephole_node(Optimizer* opt, Node* n) { Node* k; -
RealNeGate revised this gist
Mar 4, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,7 @@ Node* peephole_node(Optimizer* opt, Node* n) { // iterative convergence (rewrite peepholes): // we'll settle on a fixpoint and be happy. while (k = ideal(n), k) { n = k; } // tries to deduce the value of an op based on the // types of the inputs, if both inputs were deduced -
RealNeGate revised this gist
Mar 4, 2024 . 1 changed file with 3 additions and 23 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ // combined "Peeps + ConstProp + GVN" solver. // returns isomorphic node. Node* peephole_node(Optimizer* opt, Node* n) { Node* k; bool progress = false; @@ -9,16 +9,7 @@ Node* peephole_node(Optimizer* opt, Node* n) { // iterative convergence (rewrite peepholes): // we'll settle on a fixpoint and be happy. while (k = ideal(), k) { n = k; } // tries to deduce the value of an op based on the // types of the inputs, if both inputs were deduced @@ -48,16 +39,5 @@ Node* peephole_node(Optimizer* opt, Node* n) { return k; } return n; } -
RealNeGate revised this gist
Feb 29, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -55,7 +55,7 @@ void peephole(Optimizer* opt, Worklist* ws) { Node* n; while (n = worklist_pop(ws), n) { Node* k = peephole_node(ws, n); if (k) { if (n != k) { subsume_node(opt, n, k); } worklist_push_users(ws, k); } -
RealNeGate revised this gist
Feb 29, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -56,7 +56,7 @@ void peephole(Optimizer* opt, Worklist* ws) { while (n = worklist_pop(ws), n) { Node* k = peephole_node(ws, n); if (k != NULL) { if (n != k) { subsume_node(opt, n, k); } worklist_push_users(ws, k); } } -
RealNeGate revised this gist
Feb 29, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ // combined "Peeps + ConstProp + GVN" solver. // returns NULL if it made no progress Node* peephole_node(Optimizer* opt, Node* n) { Node* k; bool progress = false; // potential mutations from ideal() means we need to get rehash. -
RealNeGate revised this gist
Feb 29, 2024 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,7 @@ // returns NULL if it made no progress Node* peephole_node(Optimizer* opt, Node* n) { Node* k = n; bool progress = false; // potential mutations from ideal() means we need to get rehash. hashset_remove(opt->gvn_nodes, n); @@ -16,6 +17,7 @@ Node* peephole_node(Optimizer* opt, Node* n) { worklist_push_users(ws, k); n = k; } progress = true; } // tries to deduce the value of an op based on the @@ -46,9 +48,7 @@ Node* peephole_node(Optimizer* opt, Node* n) { return k; } return progress ? n : NULL; } void peephole(Optimizer* opt, Worklist* ws) { -
RealNeGate revised this gist
Feb 29, 2024 . 1 changed file with 7 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,10 @@ // combined "Peeps + ConstProp + GVN" solver. // returns NULL if it made no progress Node* peephole_node(Optimizer* opt, Node* n) { Node* k = n; // potential mutations from ideal() means we need to get rehash. hashset_remove(opt->gvn_nodes, n); // iterative convergence (rewrite peepholes): // we'll settle on a fixpoint and be happy. @@ -43,8 +46,9 @@ Node* peephole_node(Optimizer* opt, Node* n) { return k; } // either k is NULL and it's already in it's normal form or // it's not and we performed some idealize ops. return k; } void peephole(Optimizer* opt, Worklist* ws) { -
RealNeGate revised this gist
Feb 29, 2024 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -26,7 +26,8 @@ Node* peephole_node(Optimizer* opt, Node* n) { // this is ops which replace the node with a direct // input (x + 0 => x), because of this we don't need // to rerun const prop since they don't change nodes // just referenced existing ones (which are either in // normal form or waiting on the worklist). // // identity(opt, n) will always return a node, either n // or a direct replacement -
RealNeGate revised this gist
Feb 29, 2024 . 1 changed file with 14 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,23 @@ // combined "Peeps + ConstProp + GVN" solver. // returns NULL if it made no progress Node* peephole_node(Optimizer* opt, Node* n) { Node* k; // iterative convergence (rewrite peepholes): // we'll settle on a fixpoint and be happy. while (k = ideal(), k) { // we can recycle the node which means we'll make progress (k != NULL), // but don't need to move the node uses. if (n != k) { subsume_node(opt, n, k); worklist_push_users(ws, k); n = k; } } // tries to deduce the value of an op based on the // types of the inputs, if both inputs were deduced // constant we might be constant and if both inputs were // ranges we might infer extra data if not a constant. Type* t = value(opt, n); k = try_as_const(opt, n, t); -
RealNeGate revised this gist
Feb 12, 2024 . 1 changed file with 5 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -34,10 +34,13 @@ Node* peephole_node(Optimizer* opt, Node* n) { return NULL; } void peephole(Optimizer* opt, Worklist* ws) { Node* n; while (n = worklist_pop(ws), n) { Node* k = peephole_node(ws, n); if (k != NULL) { subsume_node(opt, n, k); worklist_push_users(ws, k); } } } -
RealNeGate created this gist
Feb 12, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ // combined SimpleConstProp + Identity + GVN solver. // returns NULL if it made no progress Node* peephole_node(Optimizer* opt, Node* n) { Node* k; // tries to deduce the value of an op based on the // types of the inputs, if both inputs were deduced // constant we'd be constants and if both inputs were // ranges we might infer extra data if not a constant. Type* t = value(opt, n); k = try_as_const(opt, n, t); if (k) { return k; } // this is ops which replace the node with a direct // input (x + 0 => x), because of this we don't need // to rerun const prop since they don't change nodes // just referenced existing ones. // // identity(opt, n) will always return a node, either n // or a direct replacement k = identity(opt, n); if (k != n) { return k; } // GVN, we literally just place nodes into a hash table. // no need to rerun it's ruleset if it's just referencing // an existing node. k = hashset_get(opt->gvn_nodes, n); if (k) { hashset_put(opt->gvn_nodes, k); return k; } // it's already in it's normal form (no progress) return NULL; } void peephole(Worklist* ws) { Node* n; while (n = worklist_pop(ws), n) { Node* k = peephole_node(ws, n); if (k != NULL) { worklist_push_users(ws, k); } } }