[LLVMdev] Intrinsics and dead instruction/code elimination
o.j.sivart at gmail.com
o.j.sivart at gmail.com
Wed May 19 07:07:07 PDT 2010
Hi all,
I'm interested in the impact of representing code via intrinsic functions, in contrast to via an instruction, when it comes to performing dead instruction/code elimination. As a concrete example, lets consider the simple case of the llvm.*.with.overflow.* intrinsics.
If I have some sequence (> 1) of llvm.*.with.overflow.* intrinsics, as in the form of:
@global = global i32 0
define void @fun() {
entry:
%res1 = call {i32, i1} @llvm.*.with.overflow.i32(i32 %a, i32 %b)
%sum1 = extractvalue {i32, i1} %res, 0
%obit1 = extractvalue {i32, i1} %res, 1
store i32 %obit1, i32* @global
...
%res2 = call {i32, i1} @llvm.*.with.overflow.i32(i32 %a, i32 %b)
%sum2 = extractvalue {i32, i1} %res, 0
%obit2 = extractvalue {i32, i1} %res, 1
store i32 %obit2, i32* @global
}
then I assume an optimisation pass is able to eliminate the store i32 %obit1, i32* @global, since store i32 %obit2, i32* @global clearly clobbers the global without any interleaving load/access. However, my question is whether representing code as an intrinsic limits further dead instruction/code elimination. In this case, the intrinsic will produce an arithmetic operation followed by a setcc on overflow on x86. Given the first store is dead, the first setcc on overflow instruction is also dead and can be eliminated. Is LLVM capable of such elimination with intrinsics, or is the expectation that an optimisation pass replace llvm.*.with.overflow.* intrinsics with their corresponding non-intrinsic arithmetics operations in order to achieve the same result, or is there another solution?
Thanks in advance
More information about the llvm-dev
mailing list