Difference: CS255Spring09Discussions (1 vs. 9)

Revision 92009-03-11 - ChenDing

Line: 1 to 1
 
META TOPICPARENT name="CS255Spring09"

CS255/455 Spring 2009 Discussion Board

Line: 15 to 15
  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.
Added:
>
>
A Of course it would be a nice feature of anyone's compiler to remove branch code and empty blocks. It helps the overall score since the conditional goto statement is no longer executed. The gain adds up if the branch is in a loop. Currently, unconditional gotos are not counted, but in the future they should be, so the benefit of your transformation is appropriately reflected in the instruction count.
 
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.

Revision 82009-03-11 - IanChristopher

Line: 1 to 1
 
META TOPICPARENT name="CS255Spring09"

CS255/455 Spring 2009 Discussion Board

Last 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?

Revision 72009-02-26 - BinBao

Line: 1 to 1
 
META TOPICPARENT name="CS255Spring09"

CS255/455 Spring 2009 Discussion Board

Last 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.

Revision 62009-02-24 - BinBao

Line: 1 to 1
 
META TOPICPARENT name="CS255Spring09"

CS255/455 Spring 2009 Discussion Board

Last 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

Revision 52009-02-23 - JohnPershing

Line: 1 to 1
 
META TOPICPARENT name="CS255Spring09"

CS255/455 Spring 2009 Discussion Board

Last 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

Revision 42009-02-22 - BinBao

Line: 1 to 1
 
META TOPICPARENT name="CS255Spring09"

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

Revision 32009-02-22 - JohnPershing

Line: 1 to 1
 
META TOPICPARENT name="CS255Spring09"

CS255/455 Spring 2009 Discussion Board

Last 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

  • Insert Ast::Const nodes with the same numeric value will cause problem. Thus we have slightly changed the loop.c for Project Part 2. We will provide a solution soon.

Revision 22009-02-12 - ChenDing

Line: 1 to 1
 
META TOPICPARENT name="CS255Spring09"

CS255/455 Spring 2009 Discussion Board

Last 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

  • Insert Ast::Const nodes with the same numeric value will cause problem. Thus we have slightly changed the loop.c for Project Part 2. We will provide a solution soon.
  • If the end of the string is "\n", sometimes we will lose it during the transformation. This might cause problem for scanf. E.g. run ab we generated from ab.c will require any extra input after providing two numbers. Under fixing.
  • Array supporting will come soon.

A: Each Ast node can have at most one parent. If a program has the same constants used in multiple places, each use will be represented by a different Ast::Const object. This differs from GCC implementation, in which the same constant is represented by the same Ast node.

 
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

Revision 12009-02-05 - BinBao

Line: 1 to 1
Added:
>
>
META TOPICPARENT name="CS255Spring09"

CS255/455 Spring 2009 Discussion Board

Last 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

 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding URCS? Send feedback