Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
CS255/455 Spring 2009 Discussion BoardLast year's discussion page was a success for people to discuss and share the project experience, especially their experience with GCC. So this year, we are going to continue with the discussion tradition. This page is intended for anyone to post questions and everyone to answer them. Please insert questions at the beginning and separate each question with a horizontal rule separator. For other formatting instructions read the answer to this question. | ||||||||
Added: | ||||||||
> > | Q: For project 4, we are suppose to get rid of unnecessary statements/operations using def-use chains. What about unnecessary control flow statements? a=b+c; if( a > 0 ){ d=b+a; } printf(a);Our code gets rid of d=b+a, so then the if-statement is empty. We could get rid of it. This example is very simple, but with else-statements and nested statements, things get a little more messy. Additionally we are only dealing with gotos and labels which means that we cant necessarily assume simple if-else control flow. Because we only count operations, I'm not sure this would help us in our "score", but might make the program a little nicer. | |||||||
Q: Not having access to a nodes children array can be annoying. If nothing else, and method that returns an iterator or children's length should be added in the next version. A: The children array is readable through the clone. One can get the size by using node.children_copy.length and the index of a child by node.children_copy.index(child). | ||||||||
Line: 20 to 31 | ||||||||
A: Based on the form of gimplified statements, yes, you can make that assumption to simplify your implementation.
| ||||||||
Changed: | ||||||||
< < | Q: How do you convert an int back into an INTEGER_CST? I couldn't find any reference in the documentation. | |||||||
> > | Q: How do you convert an int back into an INTEGER_CST? I couldn't find any reference in the documentation. | |||||||
Changed: | ||||||||
< < | A: Try build_int_cst, which is in tree.c | |||||||
> > | A: Try build_int_cst, which is in tree.c | |||||||
Q: I had several questions that Bin answered via e-mail. He asked me to summarize them here. It was never really detailed in class exactly what you do when you find a redundant statement. My initial thought was to simply replace the right hand side of a redundant statement with the left hand side of the statement which it was repeating. I then noticed that the success benchmark in this class how many statements we could remove from a program, and this method didn't remove any, it optimized the program by decreasing the number of operations executed, but didn't change the statement count. My next thought was that you needed to delete the statement and replace subsequent instances of the left hand side with what you would have replaced the right hand side with, but that has issues since we're only doing local value numbering, and deleting a statement could have wide spread effects in other basic blocks. So the question is what action should we take when we find a redundant statement? |
Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
CS255/455 Spring 2009 Discussion BoardLast year's discussion page was a success for people to discuss and share the project experience, especially their experience with GCC. So this year, we are going to continue with the discussion tradition. This page is intended for anyone to post questions and everyone to answer them. Please insert questions at the beginning and separate each question with a horizontal rule separator. For other formatting instructions read the answer to this question. | ||||||||
Changed: | ||||||||
< < | Q: In the intermediate language, can we assume that in an OpExpr, the operands are always either VarAcc or Const, i.e. expressions are not arbitrarily nested? | |||||||
> > | Q: Not having access to a nodes children array can be annoying. If nothing else, and method that returns an iterator or children's length should be added in the next version.
A: The children array is readable through the clone. One can get the size by using node.children_copy.length and the index of a child by node.children_copy.index(child).
Q: In Project Part2, Tasks 2 and 3 would have been much easier if I could have directly modified the id field. A: The id and children fields are read-only so to protect the integrity of the Ast node. By design the way to change a node is to create a new node and replace the old node. Q: In the intermediate language, can we assume that in an OpExpr , the operands are always either VarAcc or Const , i.e. expressions are not arbitrarily nested? | |||||||
A: Based on the form of gimplified statements, yes, you can make that assumption to simplify your implementation. |
Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
CS255/455 Spring 2009 Discussion BoardLast year's discussion page was a success for people to discuss and share the project experience, especially their experience with GCC. So this year, we are going to continue with the discussion tradition. This page is intended for anyone to post questions and everyone to answer them. Please insert questions at the beginning and separate each question with a horizontal rule separator. For other formatting instructions read the answer to this question. | ||||||||
Added: | ||||||||
> > | Q: In the intermediate language, can we assume that in an OpExpr, the operands are always either VarAcc or Const, i.e. expressions are not arbitrarily nested?
A: Based on the form of gimplified statements, yes, you can make that assumption to simplify your implementation.
| |||||||
Q: How do you convert an int back into an INTEGER_CST? I couldn't find any reference in the documentation. A: Try build_int_cst, which is in tree.c |
Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
CS255/455 Spring 2009 Discussion BoardLast year's discussion page was a success for people to discuss and share the project experience, especially their experience with GCC. So this year, we are going to continue with the discussion tradition. This page is intended for anyone to post questions and everyone to answer them. Please insert questions at the beginning and separate each question with a horizontal rule separator. For other formatting instructions read the answer to this question. | ||||||||
Changed: | ||||||||
< < | Q: I had several questions that Bin answered via e-mail. He asked me to summarize them here. It was never really detailed in class exactly what you do when you find a redundant statement. My initial thought was to simply replace the right hand side of a redundant statement with the left hand side of the statement which it was repeating. I then noticed that the success benchmark in this class how many statements we could remove from a program, and this method didn't remove any, it optimized the program by decreasing the number of operations executed, but didn't change the statement count. My next thought was that you needed to delete the statement and replace subsequent instances of the left hand side with what you would have replaced the right hand side with, but that has issues since we're only doing local value numbering, and deleting a statement could have wide spread effects in other basic blocks. So the question is what action should we take when we find a redundant statement? | |||||||
> > | Q: How do you convert an int back into an INTEGER_CST? I couldn't find any reference in the documentation.
A: Try build_int_cst, which is in tree.c
Q: I had several questions that Bin answered via e-mail. He asked me to summarize them here. It was never really detailed in class exactly what you do when you find a redundant statement. My initial thought was to simply replace the right hand side of a redundant statement with the left hand side of the statement which it was repeating. I then noticed that the success benchmark in this class how many statements we could remove from a program, and this method didn't remove any, it optimized the program by decreasing the number of operations executed, but didn't change the statement count. My next thought was that you needed to delete the statement and replace subsequent instances of the left hand side with what you would have replaced the right hand side with, but that has issues since we're only doing local value numbering, and deleting a statement could have wide spread effects in other basic blocks. So the question is what action should we take when we find a redundant statement? | |||||||
A: This question reveals a very important issue in compiler design, interaction among various compiler optimizations. It is true that we can not simply remove a redundant assignment during value numbering. But the later dead code elimination phase should be able to handle this properly. Here is an example to illustrate this. | ||||||||
Line: 13 to 18 | ||||||||
d = b + c; e = b + d; f = b + a; | ||||||||
Changed: | ||||||||
< < | should be transformed (by LVN) into | |||||||
> > | should be transformed (by LVN) into | |||||||
a = b + c; d = a; e = b + a; // here d get replaced with a. f = e; | ||||||||
Changed: | ||||||||
< < |
We also replaced d in e = b + d here, because that can eliminate a use to d . Then if there is no use to d after d = a , dead code elimination can remove d = a . However, in a real compiler, such a replacement is not always beneficial, because it will increase the lifetime of variable a , which might cause trouble to later register allocation phase. Again, here you can see the interaction among optimization phases. For our project, the metric of your compiler performance is the number of executed statements, so you don't need to worry about register allocation here. | |||||||
> > | We also replaced d in e = b + d here, because that can eliminate a use to d . Then if there is no use to d after d = a , dead code elimination can remove d = a . However, in a real compiler, such a replacement is not always beneficial, because it will increase the lifetime of variable a , which might cause trouble to later register allocation phase. Again, here you can see the interaction among optimization phases. For our project, the metric of your compiler performance is the number of executed statements, so you don't need to worry about register allocation here. | |||||||
URCC problems |
Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
CS255/455 Spring 2009 Discussion Board | ||||||||
Line: 7 to 7 | ||||||||
Q: I had several questions that Bin answered via e-mail. He asked me to summarize them here. It was never really detailed in class exactly what you do when you find a redundant statement. My initial thought was to simply replace the right hand side of a redundant statement with the left hand side of the statement which it was repeating. I then noticed that the success benchmark in this class how many statements we could remove from a program, and this method didn't remove any, it optimized the program by decreasing the number of operations executed, but didn't change the statement count. My next thought was that you needed to delete the statement and replace subsequent instances of the left hand side with what you would have replaced the right hand side with, but that has issues since we're only doing local value numbering, and deleting a statement could have wide spread effects in other basic blocks. So the question is what action should we take when we find a redundant statement? | ||||||||
Added: | ||||||||
> > | A: This question reveals a very important issue in compiler design, interaction among various compiler optimizations. It is true that we can not simply remove a redundant assignment during value numbering. But the later dead code elimination phase should be able to handle this properly. Here is an example to illustrate this.
a = b + c; d = b + c; e = b + d; f = b + a;should be transformed (by LVN) into a = b + c; d = a; e = b + a; // here d get replaced with a. f = e;We also replaced d in e = b + d here, because that can eliminate a use to d . Then if there is no use to d after d = a , dead code elimination can remove d = a . However, in a real compiler, such a replacement is not always beneficial, because it will increase the lifetime of variable a , which might cause trouble to later register allocation phase. Again, here you can see the interaction among optimization phases. For our project, the metric of your compiler performance is the number of executed statements, so you don't need to worry about register allocation here. | |||||||
URCC problems |
Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
CS255/455 Spring 2009 Discussion BoardLast year's discussion page was a success for people to discuss and share the project experience, especially their experience with GCC. So this year, we are going to continue with the discussion tradition. This page is intended for anyone to post questions and everyone to answer them. Please insert questions at the beginning and separate each question with a horizontal rule separator. For other formatting instructions read the answer to this question. | ||||||||
Added: | ||||||||
> > | Q: I had several questions that Bin answered via e-mail. He asked me to summarize them here. It was never really detailed in class exactly what you do when you find a redundant statement. My initial thought was to simply replace the right hand side of a redundant statement with the left hand side of the statement which it was repeating. I then noticed that the success benchmark in this class how many statements we could remove from a program, and this method didn't remove any, it optimized the program by decreasing the number of operations executed, but didn't change the statement count. My next thought was that you needed to delete the statement and replace subsequent instances of the left hand side with what you would have replaced the right hand side with, but that has issues since we're only doing local value numbering, and deleting a statement could have wide spread effects in other basic blocks. So the question is what action should we take when we find a redundant statement?
| |||||||
URCC problems
|
Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
CS255/455 Spring 2009 Discussion BoardLast year's discussion page was a success for people to discuss and share the project experience, especially their experience with GCC. So this year, we are going to continue with the discussion tradition. This page is intended for anyone to post questions and everyone to answer them. Please insert questions at the beginning and separate each question with a horizontal rule separator. For other formatting instructions read the answer to this question. | ||||||||
Changed: | ||||||||
< < | Q: How do we format a question and an answer? | |||||||
> > | URCC problems
| |||||||
Deleted: | ||||||||
< < | A: A question and an answer start with the bold letter Q and A respectively followed by a colon. Use italic text for the question and normal text for the answer. Use a separator (a horizontal rule) after each question. Add new questions to the beginning of the list. | |||||||
Added: | ||||||||
> > | Q: How do we format a question and an answer? A: A question and an answer start with the bold letter Q and A respectively followed by a colon. Use italic text for the question and normal text for the answer. Use a separator (a horizontal rule) after each question. Add new questions to the beginning of the list. | |||||||
-- BinBao - 05 Feb 2009 |
Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
Added: | ||||||||
> > |
CS255/455 Spring 2009 Discussion BoardLast year's discussion page was a success for people to discuss and share the project experience, especially their experience with GCC. So this year, we are going to continue with the discussion tradition. This page is intended for anyone to post questions and everyone to answer them. Please insert questions at the beginning and separate each question with a horizontal rule separator. For other formatting instructions read the answer to this question.Q: How do we format a question and an answer? A: A question and an answer start with the bold letter Q and A respectively followed by a colon. Use italic text for the question and normal text for the answer. Use a separator (a horizontal rule) after each question. Add new questions to the beginning of the list. -- BinBao - 05 Feb 2009 |