[LLVMdev] Eliminate Store-Load pair even the LoadInst is volatile

Zhou Sheng zhousheng00 at gmail.com
Thu May 22 05:56:19 PDT 2008


Hi all,

I put a case into llvm and got the following .ll code:

...
%r1419_0_0_0_i376 = alloca i32 ; <i32*> [#uses=2]
...
%tmp1476_i = lshr i32 %tmp1226_i, 24 ; <i32> [#uses=1]

store i32 %tmp1476_i, i32* %r1419_0_0_0_i376, align 4
%tmp1505_i = volatile load i32* %r1419_0_0_0_i376, align 4 ; <i32> [#uses=1]

%tmp1542_i = getelementptr [256 x i8]* @Te, i32 0, i32 %tmp1505_i
...


llvm opt can't remove the redundant store-load pair to just use the value
%tmp1476 as the load is volatile.
But I think for the above situation, it's safe to remove store-load, as the
allocad  %r1419_0_0_0_i376 just has two users (the one load and one store),
correct?

Can I add some code to instcombine or dce for this?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080522/abd6d189/attachment.html>


More information about the llvm-dev mailing list