optimization - LLVM insertvalue bad optimized? -



optimization - LLVM insertvalue bad optimized? -

should avoid using 'insertvalue' instruction combined load , store when emit llvm code? bad optimized native code when utilize it. @ next example:

; moduleid = 'mod' target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" target triple = "x86_64-pc-linux-gnu" %a = type { i64, i64, i64, i64, i64, i64, i64, i64 } @aa = external global %a* define void @func() { entry: %a1 = load %a** @aa %a2 = load %a* %a1 %a3 = insertvalue %a %a2, i64 3, 3 store %a %a3, %a* %a1 ret void }

when run "llc -o - -o3 mod.ll", horrible code:

func: # @func .ltmp0: .cfi_startproc # bb#0: # %entry movq aa(%rip), %rax movq (%rax), %r8 movq 8(%rax), %r9 movq 16(%rax), %r10 movq 32(%rax), %rdi movq 40(%rax), %rcx movq 48(%rax), %rdx movq 56(%rax), %rsi movq %rsi, 56(%rax) movq %rdx, 48(%rax) movq %rcx, 40(%rax) movq %rdi, 32(%rax) movq %r10, 16(%rax) movq %r9, 8(%rax) movq %r8, (%rax) movq $3, 24(%rax) ret

but see this:

func: # @func .ltmp0: .cfi_startproc # bb#0: # %entry movq aa(%rip), %rax movq $3, 24(%rax) ret

of course of study can utilize getelementptr or something, easier generate insertvalue , extractvalue instructions, , want these optimized...

i think quite easy codegen see things these bad:

movq 56(%rax), %rsi movq %rsi, 56(%rax)

first, note llc not ir-level optimizations. so, should run opt run set of ir-level optimizers.

however, opt not help in this. i'd expect standard ir-level optimizers canonicalize stuff gep somehow.

please file llvm pr, looks missed optimization!

optimization code-generation llvm x86-64

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -