1.4K Star 7.3K Fork 1.3K

GVP方舟编译器 / OpenArkCompiler

 / 详情

spec502----struct拷贝/赋值 优化处理

Backlog
member
Opened this issue  
2021-10-12 16:15

tree-vrp.c----vrp_visit_phi_node

LOC 47 6318
  callassigned &get_value_range (regread ptr %75) { regassign ptr %548}
  dassign %vr_arg_6312_4 4 (iread ptr <* <$value_range_d>> 4 (regread ptr %548))
  dassign %vr_arg_6312_4 3 (iread ptr <* <$value_range_d>> 3 (regread ptr %548))
  dassign %vr_arg_6312_4 2 (iread ptr <* <$value_range_d>> 2 (regread ptr %548))
  dassign %vr_arg_6312_4 1 (iread u32 <* <$value_range_d>> 1 (regread ptr %548))
	bl	get_value_range
	ldr	x1, [x0,#24]		//  [R748]  [R2153] 
	str	x1, [sp,#72]		// local var: vr_arg_6312_4 [R2153] 
	ldr	x1, [x0,#16]		//  [R748]  [R2154] 
	str	x1, [sp,#64]		// local var: vr_arg_6312_4 [R2154] 
	ldr	x1, [x0,#8]		//  [R748]  [R2155] 
	str	x1, [sp,#56]		// local var: vr_arg_6312_4 [R2155] 
	ldr	w0, [x0]		//  [R748]  [R2156] 
	str	w0, [sp,#48]		// local var: vr_arg_6312_4 [R2156] 

预期用 两条stp + 两条ldp 完成拷贝

Comments (6)

Leo Young created任务
Expand operation logs

同函数

@@253 LOC 47 6328
  dassign %vr_arg_6312_4 1 (constval u32 1)
LOC 47 6329
  dassign %vr_arg_6312_4 2 (regread ptr %599)
LOC 47 6330
  dassign %vr_arg_6312_4 3 (regread ptr %599)
LOC 47 6331
  dassign %vr_arg_6312_4 4 (constval ptr 0)
	str	w0, [sp,#48]		// local var: vr_arg_6312_4 [R2166] 
	stp	x22, x22, [sp,#56]		// local var: vr_arg_6312_4 [R799]   local var: vr_arg_6312_4 [R799] 
	str	xzr, [sp,#72]		// local var: vr_arg_6312_4

虽然field1是个u32,但是由于对齐的关系,可以当作64位存,从而提供stp机会。
预期,两条stp

FW had discussed this case and will work on it shortly

regexec.c------S_regmatch

#    freq:0
.L.2347__595:	//label order 1630
	str	w2, [x21,#36]		//  [R609]  [R3260] 
#    freq:0
.L.2347__155:	//label order 1631, MIR: @trie_first_try
	ldr	w10, [sp,#244]		//  RELOADcolor vreg: 590 op:dread
	cbz	w10, .L.2347__606
#    freq:0
	str	wzr, [sp,#244]		//  SPILLcolor vreg: 590 op:dread
	str	wzr, [sp,#240]		//  SPILLcolor vreg: 589 op:dread
 <==== 可以变成stp
@@1234   regassign i32 %1299 (iread i32 <* <$regmatch_state>> 109 (regread ptr %409))
  regassign i32 %331 (sub i32 (regread i32 %1299, constval i32 1))
LOC 36 7591
  iassign <* <$regmatch_state>> 109 (regread ptr %409, regread i32 %331)
LOC 36 7592
  brfalse @@1235 (lt u1 i32 (
    regread i32 %331,
    iread i32 <* <$regmatch_state>> 110 (regread ptr %409)))
.L.2347__1234:	//label order 1650
	ldr	w0, [x21,#56]		//  [R609]  [R1499] 
	sub	w0, w0, #1		//  [R531]  [R1499] 
	str	w0, [x21,#56]		//  [R609]  [R531] 
	ldr	w1, [x21,#60]		//  [R609]  [R12115] 
	cmp	w0, w1		//  [R531]  [R12115] 
	bge	.L.2347__1235

gcc把两次iread合并成了ldp,依旧需要考虑alias的影响,确保中间的str和下一次ldr之间没有alias关系。

.L.2347__606:	//label order 1632
	ldr	x0, [x21,#48]		//  [R609]  [R12088] 
	cbz	x0, .L.2347__607		//  [R12088] 
#    freq:0
	ldr	w0, [x25,#112]		//  [R577]  [R12089] 
	str	w0, [x21,#24]		//  [R609]  [R12089] 
	ldr	w0, [x25,#116]		//  [R577]  [R12090] 
	str	w0, [x21,#28]		//  [R609]  [R12090] 
	adrp	x0, PL_savestack_ix		//  [R12092] 
	ldr	w0, [x0, #:lo12:PL_savestack_ix]		// global: PL_savestack_ix [R12092]  [R12093] 
	str	w0, [x21,#32]		//  [R609]  [R12093] 

gcc把后两次str合并成了stp,可能需要alias帮助确认中间的ldr不会被改值

收到。

Sign in to comment

Status
Assignees
Milestones
Pull Requests
Successfully merging a pull request will close this issue.
Branches
Planed to start   -   Planed to end
-
Top level
Priority
参与者(2)
C++
1
https://git.oschina.net/openarkcompiler/OpenArkCompiler.git
git@git.oschina.net:openarkcompiler/OpenArkCompiler.git
openarkcompiler
OpenArkCompiler
OpenArkCompiler

Search

161121 f78d6d6f 1850385 154831 86f8c370 1850385