<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Feb 26, 2014, at 5:23 AM, Shemer, Anat <<a href="mailto:anat.shemer@intel.com">anat.shemer@intel.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div lang="EN-US" link="blue" vlink="purple" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class="WordSection1" style="page: WordSection1;"><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif; color: purple;">Hi Andy,<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif; color: purple;"> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif; color: purple;">Thanks a lot for looking into this.<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif; color: purple;"> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif; color: purple;">I work on a backend for OpenCL.<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt 36.75pt; font-size: 12pt; font-family: 'Times New Roman', serif; text-indent: -18.75pt;"><span style="font-size: 10pt; font-family: Verdana, sans-serif; color: purple;"><span>(1)<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-family: 'Times New Roman';"> <span class="Apple-converted-space"> </span></span></span></span><span dir="LTR"></span><span style="font-size: 10pt; font-family: Verdana, sans-serif; color: purple;"> This pattern of 64bit loop limit and 32bit IV appears in many OpenCL kernels, so I have to deal with what I get and changing the source code is not an option.<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt 36.75pt; font-size: 12pt; font-family: 'Times New Roman', serif; text-indent: -18.75pt;"><span style="font-size: 10pt; font-family: Verdana, sans-serif; color: purple;"><span>(2)<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-family: 'Times New Roman';"> <span class="Apple-converted-space"> </span></span></span></span><span dir="LTR"></span><span style="font-size: 10pt; font-family: Verdana, sans-serif; color: purple;"> I guess that you wrote LSR for a reason and that it has value so I didn’t consider this option.<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif; color: purple;"> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif; color: purple;">I have a solution that implements your option (4). However I think that this was done in order to do all operations in the same size, so this is not my first choice. It seems to me more reasonable not to take apart the ashr(shl()) in the LSR pass.<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif; color: purple;"> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif; color: purple;">Can you please advise how to do your proposed option (3)? I looked in the pass code and I couldn’t figure this out.</span></div></div></div></blockquote><div><br></div>I can think of one potential quick hack. In IVUsers.cpp, isInteresting() you could return false for a shl that looks like the first half of a sign-extend. Maybe you can see if its only user is ashr. There are other ways, but this seems quick and easy.</div><div><br></div><div>Please you file a PR with your test case and move the discussion there.</div><div><br></div><div>Thanks.</div><div><br></div><div>-Andy</div><div><br></div><div><br><blockquote type="cite"><div lang="EN-US" link="blue" vlink="purple" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class="WordSection1" style="page: WordSection1;"><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif; color: purple;"><o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif; color: purple;"> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif; color: purple;">Thanks, Anat<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif; color: purple;"> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif; color: purple;"> </span></div><div><div style="border-style: solid none none; border-top-color: rgb(181, 196, 223); border-top-width: 1pt; padding: 3pt 0in 0in;"><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><b><span style="font-size: 10pt; font-family: Tahoma, sans-serif;">From:</span></b><span style="font-size: 10pt; font-family: Tahoma, sans-serif;"><span class="Apple-converted-space"> </span>Andrew Trick [<a href="mailto:atrick@apple.com">mailto:atrick@apple.com</a>]<span class="Apple-converted-space"> </span><br><b>Sent:</b><span class="Apple-converted-space"> </span>Wednesday, February 26, 2014 06:48<br><b>To:</b><span class="Apple-converted-space"> </span>Shemer, Anat<br><b>Cc:</b><span class="Apple-converted-space"> </span><a href="mailto:llvmdev@cs.uiuc.edu">llvmdev@cs.uiuc.edu</a><br><b>Subject:</b><span class="Apple-converted-space"> </span>Re: better code for IV<o:p></o:p></span></div></div></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><o:p> </o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><o:p> </o:p></div><div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;">On Feb 18, 2014, at 11:32 PM, Shemer, Anat <<a href="mailto:anat.shemer@intel.com" style="color: purple; text-decoration: underline;">anat.shemer@intel.com</a>> wrote:<o:p></o:p></div></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><br><br><o:p></o:p></div><div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif; color: purple;">Hi Andrew,</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif; color: purple;">The issue below refers to LSR, so I’ll appreciate your feedback. It also refers to instruction combining and might impact backends other than X86, so if you know of others that might be interested you are more than welcome to add them.</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif; color: purple;">Thanks, Anat</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><o:p> </o:p></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;">I'm not sure how you ended up with that IR. You have a 64-bit index that is 32-bit sign-extended within the loop. That's not something I've seen. Normally you have a pure 64-bit index or a 32-bit sign extended index. In this case, the sign extend would be hoisted out of the loop.<o:p></o:p></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><o:p> </o:p></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;">That said, LSR has a lot of trouble with sext/zext/trunc.<o:p></o:p></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><o:p> </o:p></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;">In this case, SCEV is getting it right:<o:p></o:p></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><o:p> </o:p></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;">%idxprom = ashr exact i64 %sext, 32<o:p></o:p></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;">  -->  (sext i32 {0,+,1}<%L_entry> to i64) Exits: (sext i32 (trunc i64 (-1 + %iNumElements) to i32) to i64)<o:p></o:p></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><o:p> </o:p></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;">The presense of the shl does lose the nuw/nsw flags, but I don't think that's your problem.<o:p></o:p></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><o:p> </o:p></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;">I had to debug this a bit to understand the issue, hence my delay in answering. Some possibilities:<o:p></o:p></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><o:p> </o:p></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;">(1) Generate IR that is normally generated for C code, or change the source to match conventional patterns.<o:p></o:p></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><o:p> </o:p></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;">(2) -mllvm -disable-lsr. You'll still have two increments, but no crazy shifting. You could rewrite the code with a single counter/index and get perfect codegen.<o:p></o:p></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><o:p> </o:p></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;">(3) Teach IV-Users to see through the ashr instruction. Currently it thinks the ashr is not interesting so tells LSR to generate an expression for its operands. That's why you get the weird shifted IV. This is probably the right fix, but I can't say for sure without trying it.<o:p></o:p></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><o:p> </o:p></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;">(4) Don't let instcombine bitwise expand the trunc/sext when it feeds a gep. I'm not a big fan of the bitwise expansion but realize it was done for a reason. I don't know all of the optimizations that it exposes without doing some investigation. Before you could do this you would need to send a specific proposal titled "InstCombine should not expand trunc/sext into shl/ashr" and get the ok from other people on the list. You would also need to do performance analysis of llvm test-suite and get someone to do the same for arm.<o:p></o:p></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><o:p> </o:p></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;">-Andy<o:p></o:p></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><o:p> </o:p></div></div><blockquote style="margin-top: 5pt; margin-bottom: 5pt;"><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: purple;"> </span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: purple;"> </span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Tahoma, sans-serif;">_____________________________________________<br><b>From:</b><span class="apple-converted-space"> </span>Shemer, Anat<span class="apple-converted-space"> </span><br><b>Sent:</b><span class="apple-converted-space"> </span>Tuesday, February 18, 2014 15:07<br><b>To:</b><span class="apple-converted-space"> </span>'<a href="mailto:llvmdev@cs.uiuc.edu" style="color: purple; text-decoration: underline;">llvmdev@cs.uiuc.edu</a>'<br><b>Subject:</b><span class="apple-converted-space"> </span>better code for IV</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 11pt; font-family: Calibri, sans-serif;"> </span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 11pt; font-family: Calibri, sans-serif;"> </span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif;">Hi,<o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif;"> <o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif;">I will be glad if you can give me some advice on how to make LLVM generate better code for IV in a simple loop case. There is IR sample below, I know of one way to do it, and I’m looking for advice on another way.<o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif;"> <o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif;">When compiling a simple C loop (c[i]=a[i]+b[i], a, b, c are float*), the IR starts as follows:<o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif;"> <o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">        define void @ArrayAdd1(float* nocapture %a, float* nocapture %b, float* nocapture %c, i64 %iNumElements) {</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">        Entry:</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          br label %L_pre_head</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';"> </span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">        L_pre_head:                                       ; preds = %Entry</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          br label %L_entry</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';"> </span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">        L_entry:                                          ; preds = %L_entry, %L_pre_head</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          %L_ind_var = phi i64 [ 0, %L_pre_head ], [ %L_inc_ind_var, %L_entry ]</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          %L_tid = phi i64 [ 0, %L_pre_head ], [ %L_inc_tid, %L_entry ]</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          %trunc = trunc i64 %L_tid to i32</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          %idxprom = sext i32 %trunc to i64</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          %arrayidx = getelementptr inbounds float* %a, i64 %idxprom</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          %0 = load float* %arrayidx, align 4</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          %arrayidx2 = getelementptr inbounds float* %b, i64 %idxprom</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          %1 = load float* %arrayidx2, align 4</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          %add = fadd float %0, %1</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          %arrayidx4 = getelementptr inbounds float* %c, i64 %idxprom</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          store float %add, float* %arrayidx4, align 4</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          %L_inc_ind_var = add nuw nsw i64 %L_ind_var, 1</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          %L_cmp.to.max = icmp eq i64 %L_inc_ind_var, %iNumElements</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          %L_inc_tid = add nuw nsw i64 %L_tid, 1</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          br i1 %L_cmp.to.max, label %L_exit, label %L_entry</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';"> </span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">        L_exit:                                           ; preds = %L_entry</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          br label %2</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';"> </span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">        ; <label>:2                                       ; preds = %L_exit</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          ret void</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">        }</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 11pt; font-family: Calibri, sans-serif;"> </span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif;">And after going through all passes before code generation it becomes:<o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif;"> <o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">        define void @ArrayAdd1(float * nocapture %a, float * nocapture %b, float * nocapture %c, i64 %iNumElements)</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">        {</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">        Entry:</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          br label %L_pre_head</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';"> </span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">        L_pre_head:                                   ; preds = %Entry</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          br label %L_entry</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';"> </span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">        L_entry:                              ; preds = %L_entry, %L_pre_head</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          %L_ind_var = phi i64 [ 0, %L_pre_head ], [ %L_inc_ind_var, %L_entry ]</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          %L_tid = phi i64 [ 0, %L_pre_head ], [ %L_inc_tid, %L_entry ]</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          %sext = shl i64 %L_tid, 32</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          %idxprom = ashr exact i64 %sext, 32</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          %arrayidx = getelementptr inbounds float * %a, i64 %idxprom</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          %0 = load float * %arrayidx, align 4</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          %arrayidx2 = getelementptr inbounds float * %b, i64 %idxprom</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          %1 = load float * %arrayidx2, align 4</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          %add = fadd float %0, %1</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          %arrayidx4 = getelementptr inbounds float * %c, i64 %idxprom</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          store float %add, float * %arrayidx4, align 4</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          %L_inc_ind_var = add nuw nsw i64 %L_ind_var, 1</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          %L_cmp.to.max = icmp eq i64 %L_inc_ind_var, %iNumElements</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          %L_inc_tid = add nuw nsw i64 %L_tid, 1</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          br i1 %L_cmp.to.max, label %L_exit, label %L_entry</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';"> </span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">        L_exit:                                       ; preds = %L_entry</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          br label %2</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';"> </span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">        ; <label>:2                                       ; preds = %L_exit</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          ret void</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">        }</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 11pt; font-family: Calibri, sans-serif;"> </span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif;">On the way to code gen the IR goes through some additional passes, among them the LSR in LoopStrengthReduce.cpp. This pass promotes the shl operation out of the loop. As a result the generated code is awkward and uses 4 registers for IV management instead of 2 (see transformed IR and result asm below).<o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif;"> <o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif;">One way to deal with this is to prevent the transformation of<o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">      %trunc = trunc i64 %L_tid to i32</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">      %idxprom = sext i32 %trunc to i64</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif;">to<o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">      %sext = shl i64 %L_tid, 32</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">      %idxprom = ashr exact i64 %sext, 32</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 11pt; font-family: Calibri, sans-serif;"> </span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif;">Sext(trunk()) remains nice until code gen and one asm instruction of the sort “move %eax, %rax” is generated, as I want (see asm sample at the end of this message). I implemented this locally in InstCombineCasts.cpp, in InstCombiner::visitSExt(). The code looks for the specific pattern of sext32to64(trunk64to32()) and doesn’t let it become ashr(shl()).<o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif;"> <o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif;">Another way that I can think of, is to keep ashr32(shl32()) together and then it’s possible to replace both instructions with one asm instruction (a la  “move %eax, %rax”) and avoid an additional register for monitoring end of loop. I’m not sure what is the right point in LSRInstance::LSRInstance to avoid this optimization.<o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif;"> <o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif;">Do you think that the first way is ok? If you think that this should be done in the second way or a third way I will appreciate your guidance.<o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif;"> <o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif;">Thanks, Anat<o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif;"> <o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif;"> <o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif;">The IR after LSR:<o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">        define void @ArrayAdd1(float* nocapture %a, float* nocapture %b, float* nocapture %c, i64 %iNumElements) {</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">        Entry:</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          br label %L_pre_head</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';"> </span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">        L_pre_head:                                       ; preds = %Entry</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          br label %L_entry</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';"> </span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">        L_entry:                                          ; preds = %L_entry, %L_pre_head</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          %lsr.iv1 = phi i64 [ %lsr.iv.next2, %L_entry ], [ 0, %L_pre_head ]</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          %lsr.iv = phi i64 [ %lsr.iv.next, %L_entry ], [ %iNumElements, %L_pre_head ]</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          %idxprom = ashr exact i64 %lsr.iv1, 32</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          %arrayidx = getelementptr inbounds float* %a, i64 %idxprom</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          %0 = load float* %arrayidx, align 4</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          %arrayidx2 = getelementptr inbounds float* %b, i64 %idxprom</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          %1 = load float* %arrayidx2, align 4</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          %add = fadd float %0, %1</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          %arrayidx4 = getelementptr inbounds float* %c, i64 %idxprom</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          store float %add, float* %arrayidx4, align 4</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          %lsr.iv.next = add i64 %lsr.iv, -1</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          %lsr.iv.next2 = add i64 %lsr.iv1, 4294967296</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          %L_cmp.to.max = icmp eq i64 %lsr.iv.next, 0</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          br i1 %L_cmp.to.max, label %L_exit, label %L_entry</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';"> </span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">        L_exit:                                           ; preds = %L_entry</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          br label %2</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';"> </span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">        ; <label>:2                                       ; preds = %L_exit</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">          ret void</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">        }</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 11pt; font-family: Calibri, sans-serif;"> </span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif;">Asm code:<o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">    ArrayAdd1:                              # @ArrayAdd1</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">            .cfi_startproc</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">    # BB#0:                                 # %Entry</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">            xorl    %r9d, %r9d</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">            movabsq $4294967296, %r8        # imm = 0x100000000</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">            .align  16, 0x90</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">    .LBB0_1:                                # %L_entry</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">                                            # =>This Inner Loop Header: Depth=1</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">            movq    %r9, %rax</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">            sarq    $32, %rax</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">            movss   (%rdi,%rax,4), %xmm0</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">            addss   (%rsi,%rax,4), %xmm0</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">            movss   %xmm0, (%rdx,%rax,4)</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">            addq    %r8, %r9</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">            decq    %rcx</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">            jne     .LBB0_1</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">    # BB#2:</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">            Ret</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 11pt; font-family: Calibri, sans-serif;"> </span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: Verdana, sans-serif;">This is what I want to get:<o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">    ArrayAdd2:                              # @ArrayAdd2</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">            .cfi_startproc</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">    # BB#0:                                 # %Entry</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">            xorl    %eax, %eax</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">            .align  16, 0x90</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">    .LBB1_1:                                # %L_entry</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">                                            # =>This Inner Loop Header: Depth=1</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">            movslq  %eax, %r8</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">            movss   (%rdi,%r8,4), %xmm0</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">            addss   (%rsi,%r8,4), %xmm0</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">            movss   %xmm0, (%rdx,%r8,4)</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">            incq    %rax</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">            cmpq    %rax, %rcx</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">            jne     .LBB1_1</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">    # BB#2:</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 10pt; font-family: 'Courier New';">            Ret</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 11pt; font-family: Calibri, sans-serif;"> </span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 11pt; font-family: Calibri, sans-serif;"> </span><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><o:p></o:p></span></div></div><p style="margin-right: 0in; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9pt; font-family: Helvetica, sans-serif;">---------------------------------------------------------------------<br>Intel Israel (74) Limited<o:p></o:p></span></p><p style="margin-right: 0in; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 9pt; font-family: Helvetica, sans-serif;">This e-mail and any attachments may contain confidential material for<br>the sole use of the intended recipient(s). Any review or distribution<br>by others is strictly prohibited. If you are not the intended<br>recipient, please contact the sender and delete all copies.<o:p></o:p></span></p></blockquote></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><o:p> </o:p></div></div><p style="margin-right: 0in; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman', serif;">---------------------------------------------------------------------<br>Intel Israel (74) Limited</p><p style="margin-right: 0in; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman', serif;">This e-mail and any attachments may contain confidential material for<br>the sole use of the intended recipient(s). Any review or distribution<br>by others is strictly prohibited. If you are not the intended<br>recipient, please contact the sender and delete all copies.</p></div></blockquote></div><br></body></html>