-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a new fusion instruction and remove unnecessary ones #227
Conversation
a39abe4
to
7a20998
Compare
7a20998
to
4612360
Compare
4612360
to
4dbfe8d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consistently employ the prefix constopt_
rather than const_opt
to prevent potential confusion.
Both constant folding and constant propagation are related compiler optimization techniques. Constant propagation replaces the bound variable with the constant expression it is bound to. Conversely, constant folding evaluates the expression with all compile-time inputs. I am a bit confused about the proposed changes, as I cannot ensure that a fully functional implementation exists for either constant folding or constant propagation. Can you verify this? |
With constant propagation and constant folding, we can optimize some ALU or brnach instructions into simple instructions. See: sysprog21#226
4dbfe8d
to
b7af015
Compare
There is a simple example in
Moreover, these 6 |
b7af015
to
af94d6a
Compare
Describe this within git commit messages. |
af94d6a
to
05068a9
Compare
05068a9
to
d36f0d6
Compare
After constant propagation and constant folding, auipc + addi and lui + addi become 2 lui instuctions. Moreover, we discover a sequence of lui instrution existing in optimized basic block, so we add a new fusion function to handle multiple lui instructions. There is a simple example in ./build/dhrystone.elf can be optimized by constant folding and constant propagation. Before 0x100f0: auipc gp,0x18 0x100f4: add gp,gp,864 0x100f8: add a0,gp,-1996 0x100fc: auipc a2,0x1a 0x10100: add a2,a2,1384 0x10104: sub a2,a2,a0 After 0x100f0: lui gp, 0x10108 0x100f4: lui gp, 0x10468 0x100f8: lui a0, 0xFC9C 0x100fc: lui a2,0x10116 0x10100: lui a2, 0x1067E 0x10104: lui a2, 0x9e2 Moreover, these 6 lui instructions can be fused into a fused instruction.
d36f0d6
to
0d1f7f3
Compare
After constant propagation and constant folding, we can optimize some ALU or brnach instructions into simple instructions.
Close: #226