1.4K Star 7.6K Fork 1.4K

GVP方舟编译器 / OpenArkCompiler

 / 详情

【spec性能分析】特别场景下div/mul指令优化

待办的
成员
创建于  
2021-08-05 11:19
  • 源码:spec 525 pixel.c 函数:abs2

C源码:

static ALWAYS_INLINE uint32_t abs2( uint32_t a )
{
    uint32_t s = ((a>>15)&0x10001)*0xffff;    <======  "*0xffff 存在优化空间"
    return (a+s)^s;
}

GCC汇编:

lsr    w5, w4, #15
and    w7, w5, #0x10001
lsl    w5, w7, #16   <====== "当做 reg*0x10000 - reg"
sub    w5, w5, w7

maple里原本此类优化在后端实现,但是由于后端没有数据流,无法判断reg*0x10000 是否会溢出,所以关闭,建议在中端数据流的配合下进行优化。

评论 (1)

Leo Young 创建了任务
展开全部操作日志

源码:spec500 pp_ctl.c 函数:Perl_pp_enter

maple:

22545   regassign i64 %13 (sub i64 (regread i64 %11, regread i64 %12))
22546   regassign i64 %14 (div i64 (regread i64 %13, constval i64 8))

maple汇编:

16678   asr x1, x2, #63
16679   add x1, x2, x1, LSR #61
16680   asr x1, x1, #3  // x1 = x2 / 8

gcc汇编:

asr x0, x0, 3
fredchow 添加协作者fredchow

登录 后才可以发表评论

状态
负责人
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
参与者(2)
C++
1
https://gitee.com/openarkcompiler/OpenArkCompiler.git
git@gitee.com:openarkcompiler/OpenArkCompiler.git
openarkcompiler
OpenArkCompiler
OpenArkCompiler

搜索帮助