<font color="#000000"><font face="verdana,sans-serif">Ok. Let me describe the problem again in some detail.<br></font></font><div><font class="Apple-style-span" face="verdana, sans-serif"><br></font></div><div><font class="Apple-style-span" face="verdana, sans-serif">The following is the original bitcode from a real testcase:<br>

</font></div><div><div class="gmail_quote">  </div><div class="gmail_quote"><div class="gmail_quote"><font class="Apple-style-span" color="#000099">bb7:                                           </font></div><div class="gmail_quote">

<font class="Apple-style-span" color="#000099">  %46 = load i32* %j, align 4</font></div><div class="gmail_quote"><font class="Apple-style-span" color="#000099">  %47 = add nsw i32 %46, 1</font></div><div class="gmail_quote">

<font class="Apple-style-span" color="#000099">  store i32 %47, i32* %j, align 4</font></div><div class="gmail_quote"><font class="Apple-style-span" color="#000099">  br label %bb8</font></div></div><div class="gmail_quote">

<br></div><div class="gmail_quote">To protect the operand of the store I duplicate the input chain of operands and insert a comparison to check whether the operand of the stores are correct. As a result of this modification the code looks as follows. Here instructions with HV in there name are extra inserted instructions and relExit BB contains a printf message which is executed if the comparison fails. This is the final code which is supposed to execute on a simulator or real hardware.</div>

<div class="gmail_quote"><br></div><div class="gmail_quote">bb7:</div><div class="gmail_quote">  %46 = load i32* %j, align 4</div><div class="gmail_quote">  %47 = add nsw i32 %46, 1</div><div class="gmail_quote">  %HV7_ = add nsw i32 %46, 1</div>

<div class="gmail_quote">  %HVCmp13 = icmp ne i32 %47, %HV7_</div><div class="gmail_quote">  br i1 %HVCmp13, label %relExit, label %bb7.split</div><div class="gmail_quote"><br></div><div class="gmail_quote"><div class="gmail_quote">

bb7.split:                                        </div><div class="gmail_quote">  store i32 %47, i32* %j, align 4</div><div class="gmail_quote">  br label %bb8</div><div class="gmail_quote"><br></div><div class="gmail_quote">

The following is the arm code generated for the above block (llc with -O0):</div><div class="gmail_quote"><br></div><div class="gmail_quote"><div class="gmail_quote">.LBB0_26:                               @ %bb7</div><div class="gmail_quote">

                                        @   in Loop: Header=BB0_28 Depth=2</div><div class="gmail_quote">  ldr r0, [sp, #440]</div><div class="gmail_quote">  add r0, r0, #1</div><div class="gmail_quote">  cmp r0, r0</div>

<div class="gmail_quote">  str r0, [sp, #288]</div><div class="gmail_quote">  bne .LBB0_88</div><div class="gmail_quote">  b .LBB0_27</div><div class="gmail_quote">.LBB0_27:                               @ %bb7.split</div>

<div class="gmail_quote">                                        @   in Loop: Header=BB0_28 Depth=2</div><div class="gmail_quote">  ldr r0, [sp, #288]</div><div class="gmail_quote">  str r0, [sp, #440]</div><div><br></div>

<div>The code generated for x86 for the same two blocks looks like as follows (again llc with -O0):</div><div><br></div><div><div>.LBB0_26:                               # %bb7</div><div>                                              #   in Loop: Header=BB0_28 Depth=2</div>

<div>  movl  564(%esp), %eax</div><div>  movl  %eax, 400(%esp)          # 4-byte Spill</div><div>  addl  $1, %eax</div><div>  movl  400(%esp), %ecx         # 4-byte Reload</div><div>  addl  $1, %ecx</div><div>  cmpl  %ecx, %eax</div>

<div>  movl  %eax, 396(%esp)         # 4-byte Spill</div><div>  jne .LBB0_88</div><div># BB#27:                               # %bb7.split</div><div>                                            #   in Loop: Header=BB0_28 Depth=2</div>

<div>  movl  396(%esp), %eax         # 4-byte Reload</div><div>  movl  %eax, 564(%esp)</div></div><div><br></div><div>The problem here is in case of ARM code generation the backend has effectively removed the comparison (its comparing same register) of different computations. I want to have that comparison in the final code. The final code would be running on a hardware or simulator so that whenever a transient error occurs I can detect that and trigger a recovery. My goal here is to achieve the duplicated computation (same as visible in x86 asm e.g. adding the one twice) for ARM. Is there a way I can achieve it? </div>

<div><br></div><div>Does the problem make more sense now? Thank you for your help.</div><div><br></div><div>Thanks</div><div>Daya</div><div><br></div><div><br></div></div></div><div class="gmail_quote">On Thu, Jul 7, 2011 at 4:05 AM, Renato Golin <span dir="ltr"><<a href="mailto:renato.golin@arm.com">renato.golin@arm.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">On 7 July 2011 00:02, D S Khudia <<a href="mailto:daya.khudia@gmail.com">daya.khudia@gmail.com</a>> wrote:<br>


> I am trying to add a intrinsic call between the similar two instructions<br>
> which either I'll remove or convert to nop in codegen.<br>
<br>
</div>If the two instructions are only similar in your real example, than<br>
you need to make them similar in your test, not identical. Different<br>
offsets, different array...<br>
<br>
If them two are identical in the real example as it is in your test,<br>
than you don't need to worry about it, because the back-end will<br>
remove them anyway.<br>
<div class="im"><br>
<br>
> Does that kind of seem appropriate for the purpose here?<br>
<br>
</div>If you're adding the builtin call just to mark the code in some way, I<br>
suggest you using metadata. If that builtin has some function that is<br>
necessary in between two similar instructions, than it looks ok.<br>
<br>
Sorry if I'm being vague, I'm not fully getting the original problem...<br>
<br>
cheers,<br>
<font color="#888888">--renato<br>
</font></blockquote></div><br></div>