CS243: Program Analysis and Optimizations Winter 2026
This page is updated frequently, so check back often. All materials for the course will be posted here.What do we teach?
- How do we make high-level programming languages efficient by optimizing the code? (Data-flow analysis)
- Machine learning and scientific computing need a lot of cycles; machines such as GPUs are complex to code. How do we automatically generate efficient code for these machines effectively. (Parallelism and Locality)
- Can we use program analysis to improve the quality of the code? (Satisfiability Modulo Theories)
- How do we automatically manage memory efficiently so users do not have to manage it themselves? (Garbage collection)
- The highest programming language is obviously natural language. With the recent introduction of large language models such as ChatGPT, how do we let consumers code in natural language using machine learning? Note: no prior knowledge in machine learning is needed. (Neural networks)
How do you learn this?
As compilers are one of the most complex programs we write, by teaching compilers, we are also teaching software engineering. It is a course where programming and mathematics meet. We show how to apply general mathematical concepts (fixpoint computations, graph theory, linear algebra, binary decision diagrams, neural networks) to handle various complex programming problems. You will learn how to formulate solutions to problems, and not just memorizing prior work.
How is the course structured?
- Interactive lectures, textbook reading.
- Programming assignments analyze Java code.
- Written assignments explore mathematical concepts from lectures.
- Problem sessions for discussion.
- Ed for offline questions.
- 2 Exams.
Logistics When, where, what and how
| Lectures | Monday and Wednesday 3:00 pm - 4:20 pm, Thorton 102 |
| Review Session | Friday 2:30 pm - 3:20 pm, Gates B01 (starting Jan 16th) |
| Prerequisites | CS 103 or CS 103B, and CS 107; Java programming language experience |
| Textbook | Compilers: Principles, Techniques, and Tools (Second Edition), Alfred V. Aho, Monica S. Lam, Ravi Sethi, Jeffrey D. Ullman, Addison-Wesley, 2007. |
| Class Q&A Website | CS243 on Ed, for all questions related to course material |
| Videos of Lectures | CS243 Canvas Page |
| Staff Mailing List | cs243-win2526-staff@lists.stanford.edu |
| Office Hours Sign-up | QueueStatus |
| SCPD Office Hours | Sign-up on QueueStatus, write SCPD in name |
| Midterm | Wednesday, Feb 11, 2026: 3:00pm - 4:20pm (in class), Thorton Center 102 |
| Final Exam | Tuesday, Mar 17, 2026: 8.30am - 11.30am, Thorton Center 102 |
Staff Professor and TA details
Monica Lam, Instructor
| Office | Gates 368 |
| Office Hours | Wednesdays: after class |
| Contact Details |
Angelica Teaupa, Admin
| Office | Gates 462 |
| Phone | (650) 724-5040 |
Matthew Sotoudeh, TA
| Office | CoDa W326 (preferred) and Zoom |
| Office Hours |
Monday 10am - 12pm (postponed to Wednesday for Presidents' Day)
Tuesday 3pm - 5pm Email if you can't make those |
| Contact Details | sotoudeh@stanford.edu |
Billy Bao, TA
| Office | Huang Basement and Zoom |
| Office Hours | Monday 6pm - 7pm (Zoom) / Thursday 3pm - 4pm (Huang Basement) |
| Contact Details | billybao@stanford.edu |
Tentative Schedule Subject to change
| Date | Topic | Reading | Lecture notes | Assignment out | Assignment due | Review Session (Fri) |
|---|---|---|---|---|---|---|
| Jan 5 [Mon] | Introduction | 1.1-5, 8.4, 8.5, 9.1 | Lecture 1 | |||
| Jan 7 [Wed] | Dataflow Analysis Introduction | 9.2 | Lecture 2 | |||
| Jan 12 [Mon] | Dataflow Analysis Foundation | 9.3 | Lecture 3 | |||
| Jan 14 [Wed] | Constant Propagation, Loops | 9.4, 9.6 | Lecture 4 | HW1 | Data flow analysis | |
| Jan 19 [Mon] | holiday | |||||
| Jan 21 [Wed] | Partial Redundancy Elimination | 9.5 | Lecture 5 | HW2, Starter Code, JoeQ Documentation | HW1 | JoeQ |
| Jan 26 [Mon] | Register Allocation | 8.8 | Lecture 6 | |||
| Jan 28 [Wed] | Instruction Scheduling | 10.1–10.4 | Lecture 7 | HW3, Gradiance | HW2 | HW3 |
| Feb 2 [Mon] | Software Pipelining | 10.5 | Lecture 8 | |||
| Feb 4 [Wed] | Parallelization | 11.1–11.4, 11.6 | Lecture 9 | HW4, Starter Code | HW3 | Midterm Review |
| Feb 9 [Mon] | Loop Transformations | 11.7-11.9 | Lecture 10 | |||
| Feb 11 [Wed] | Midterm (in class) | See Canvas for practice midterms | ||||
| Feb 16 [Mon] | holiday | |||||
| Feb 18 [Wed] | Pipelined Parallelism | 11.8, 11.9 | HW4 | |||
| Feb 23 [Mon] | Locality + Parallelism | 11.9 - 11.11 | ||||
| Feb 25 [Wed] | SSA and SMT (Satisfiability Modulo Theories) Intro | |||||
| Mar 2 [Mon] | SMT Solvers | |||||
| Mar 4 [Wed] | Garbage Collection | 7.4-7.7.4 | ||||
| Mar 9 [Mon] | Pointer Analysis | 12 | ||||
| Mar 11 [Wed] | Automatic Coding with LLMs | |||||
| Mar 17 [Tue] | Final (8:30am - 11:30am), Location: Thorton Center 102 |
Handouts and Graded Assignments
Lecture notes will be available for download by the morning of the lecture. Assignment handouts will be available on this page on the day it is assigned. Unless otherwise stated, written assignments should be submitted through Gradescope.
CS243 will be using the Gradiance automated homework system for some of
the required work. You should open your free account at
www.gradiance.com/services
and then sign up for the class using the "class token" E2480399.
Gradiance looks like multiple-choice questions, but it is really quite different. You are given problems to work out, just as you would in an ordinary homework. You are then given a multiple-choice question to test whether or not you have the correct solution. If you get a choice wrong, you are given a hint and encouraged to try again. You are allowed to try as many times as you like, and the goal is to get everything right eventually. To avoid repeated guessing on one problem at a time, you need to repeat all the questions each time you submit, and you will be given a different set of choices each time.
Assignment Policy
Group Work
Homework will consist of both written and programming assignments. You are encouraged to work on the programming assignments in groups of two, but you must do the written assignments by yourself.
Late Policy
In general, no late assignments are accepted. However, you have two grace days for the entire quarter. That means you can be late by one day for two assignments, or use the two days up for one assignment.
Submission
Programming assignments will have specific submission instructions included with the handouts. We will use a certain amount of automatic grading to help us deal with the massive amounts of code everyone submits, so please follow the submission instructions exactly as written!
The written homework should be submitted via Gradescope. You may access Gradescope through the corresponding tab in Canvas.
We will also assign some homework via Gradiance, as described above. If you have any issues accessing the Gradiance site, please contact the TAs.
Honor Code Cheating and Plagiarism is a no-no
You are free to discuss the assignment and solutions with others. However, you must write your own assignment, and must not represent any portion of others' work as your own. Anybody violating the honor code will be referred to the Office of Community Standards. If convicted, the normal penalty is a quarter suspension or worse.