forked from gcc-mirror/gcc
-
Notifications
You must be signed in to change notification settings - Fork 20
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
关于分支消除的实现 #106
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
0x0
对于指令流中的分支指令cpu对其分支预测失败后会导致刷流水线,进而导致性能下降
最好的解决方式是不产生分支指令,而在高级语言中对于一些结构简单的if-then-else语句我们可以尝试对其实施分支消除
0x1
下面我们在c语言中对于a、b比较,根据比较结果将c或d赋值给out(其中a、b、c、d、out为变量)的情况进行分析讨论
以下为测试代码模板
根据abcd变量类型的不同我们考虑以下4种情况,并设计其分支消除的指令序列
abcd全为定点
全为定点可以使用以下序列,现有gcc后端代码已经实现
abcd全为浮点
现有gcc后端代码已经实现
ab为浮点cd为定点
这种情况有两种方案
第一种是使用浮点fcmp,然后将fcc使用movcf2gr 移动到通用寄存器,再使用maskeqz masknez or
第二种将c、d使用movgr2fr移动到浮点寄存器,再进行浮点分支消除,完成后再将结果使用movfr2gr
ab为定点cd为浮点
这种情况和上一种情况一样也有两种方案
第一种,将stl结果使用movgr2cf到fcc再使用浮点fsel
第二种将定点数据移动到浮点寄存器,转换为浮点数据,再作浮点分支消除
0x2
为了实现分支消除我们需要对la后端作以下改动
The text was updated successfully, but these errors were encountered: