<div dir="ltr">The C source code:<div><br></div><div><p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style="">__kernel void adi_kernel</span><span style="color:rgb(195,55,32)">1</span><span style="color:rgb(213,59,211)">(</span><span style="">__global DATA_TYPE* A, __global DATA_TYPE* B, __global DATA_TYPE* X, int n</span><span style="color:rgb(213,59,211)">)</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style="">{</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> int i</span><span style="color:rgb(195,55,32)">1</span><span style=""> </span><span style="color:rgb(206,121,36)">=</span><span style=""> get_global_id</span><span style="color:rgb(213,59,211)">(</span><span style="color:rgb(195,55,32)">0</span><span style="color:rgb(213,59,211)">)</span><span style="color:rgb(83,48,225)">;</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> int i</span><span style="color:rgb(195,55,32)">2</span><span style="color:rgb(83,48,225)">; </span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0);min-height:14px"><span style=""></span><br></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> </span><span style="color:rgb(206,121,36)">if</span><span style=""> </span><span style="color:rgb(213,59,211)">((</span><span style="">i1 </span><span style="color:rgb(206,121,36)"><</span><span style=""> n</span><span style="color:rgb(213,59,211)">))</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> {</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(83,48,225);background-color:rgb(0,0,0)"><span style="color:rgb(77,186,43)"> for </span><span style="color:rgb(213,59,211)">(</span><span style="color:rgb(77,186,43)">i2 </span><span style="color:rgb(206,121,36)">=</span><span style="color:rgb(77,186,43)"> </span><span style="color:rgb(195,55,32)">1</span><span style="">; i2 < n; i2++)</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> {</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> X[i1*n </span><span style="color:rgb(206,121,36)">+</span><span style=""> i2] </span><span style="color:rgb(206,121,36)">=</span><span style=""> X[i1*n </span><span style="color:rgb(206,121,36)">+</span><span style=""> i2] </span><span style="color:rgb(206,121,36)">-</span><span style=""> X[i1*n </span><span style="color:rgb(206,121,36)">+</span><span style=""> </span><span style="color:rgb(213,59,211)">(</span><span style="">i2-1</span><span style="color:rgb(213,59,211)">)</span><span style="">] </span><span style="color:rgb(206,121,36)">*</span><span style=""> A[i1*n </span><span style="color:rgb(206,121,36)">+</span><span style=""> i2] </span><span style="color:rgb(206,121,36)">/</span><span style=""> B[i1*n </span><span style="color:rgb(206,121,36)">+</span><span style=""> </span><span style="color:rgb(213,59,211)">(</span><span style="">i2-1</span><span style="color:rgb(213,59,211)">)</span><span style="">]</span><span style="color:rgb(83,48,225)">;</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> B[i1*n </span><span style="color:rgb(206,121,36)">+</span><span style=""> i2] </span><span style="color:rgb(206,121,36)">=</span><span style=""> B[i1*n </span><span style="color:rgb(206,121,36)">+</span><span style=""> i2] </span><span style="color:rgb(206,121,36)">-</span><span style=""> A[i1*n </span><span style="color:rgb(206,121,36)">+</span><span style=""> i2] </span><span style="color:rgb(206,121,36)">*</span><span style=""> A[i1*n </span><span style="color:rgb(206,121,36)">+</span><span style=""> i2] </span><span style="color:rgb(206,121,36)">/</span><span style=""> B[i1*n </span><span style="color:rgb(206,121,36)">+</span><span style=""> </span><span style="color:rgb(213,59,211)">(</span><span style="">i2-1</span><span style="color:rgb(213,59,211)">)</span><span style="">]</span><span style="color:rgb(83,48,225)">;</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> }</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> }</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style="">}</span></p></div><div><br></div><div>Only one induction variable (i2) in the source. But in the IR i2.087 and indvars.iv are all induction variables (I think). Any body know why this happens? Is there a way to generate only one induction variables?</div><div><br></div><div><p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style="">; Function Attrs: nounwind ssp uwtable</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style="">define void @adi_kernel1(float* nocapture readonly %A, float* nocapture %B, float* nocapture %X, i32 %n) #0 {</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style="">entry:</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> %call = tail call i32 (i32, ...) bitcast (i32 (...)* @get_global_id to i32 (i32, ...)*)(i32 0) #2</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> %cmp = icmp slt i32 %call, %n</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> %cmp186 = icmp sgt i32 %n, 1</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> %or.cond = and i1 %cmp, %cmp186</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> br i1 %or.cond, label %<a href="http://for.body.lr.ph">for.body.lr.ph</a>, label %if.end</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0);min-height:14px"><span style=""></span><br></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""><a href="http://for.body.lr.ph">for.body.lr.ph</a>: ; preds = %entry</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> %mul = mul nsw i32 %call, %n</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> %sub = add i32 %mul, -1</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> br label %for.body</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0);min-height:14px"><span style=""></span><br></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style="">for.body: ; preds = %for.body, %<a href="http://for.body.lr.ph">for.body.lr.ph</a></span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> %indvars.iv = phi i64 [ 1, %<a href="http://for.body.lr.ph">for.body.lr.ph</a> ], [ %indvars.iv.next, %for.body ]</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> %i2.087 = phi i32 [ 1, %<a href="http://for.body.lr.ph">for.body.lr.ph</a> ], [ %inc, %for.body ]</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> %add = add nsw i32 %i2.087, %mul</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> %idxprom = sext i32 %add to i64</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> %arrayidx = getelementptr inbounds float, float* %X, i64 %idxprom</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> %0 = load float, float* %arrayidx, align 4, !tbaa !8</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> %1 = trunc i64 %indvars.iv to i32</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> %add3 = add i32 %sub, %1</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> %idxprom4 = sext i32 %add3 to i64</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> %arrayidx5 = getelementptr inbounds float, float* %X, i64 %idxprom4</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> %2 = load float, float* %arrayidx5, align 4, !tbaa !8</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> %arrayidx9 = getelementptr inbounds float, float* %A, i64 %idxprom</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> %3 = load float, float* %arrayidx9, align 4, !tbaa !8</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> %mul10 = fmul float %2, %3</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> %arrayidx15 = getelementptr inbounds float, float* %B, i64 %idxprom4</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> %4 = load float, float* %arrayidx15, align 4, !tbaa !8</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> %div = fdiv float %mul10, %4, !fpmath !12</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> %sub16 = fsub float %0, %div</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> store float %sub16, float* %arrayidx, align 4, !tbaa !8</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> %arrayidx24 = getelementptr inbounds float, float* %B, i64 %idxprom</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> %5 = load float, float* %arrayidx24, align 4, !tbaa !8</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> %6 = load float, float* %arrayidx9, align 4, !tbaa !8</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> %mul33 = fmul float %6, %6</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> %7 = load float, float* %arrayidx15, align 4, !tbaa !8</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> %div39 = fdiv float %mul33, %7, !fpmath !12</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> %sub40 = fsub float %5, %div39</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> store float %sub40, float* %arrayidx24, align 4, !tbaa !8</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> %inc = add nuw nsw i32 %i2.087, 1</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> %lftr.wideiv = trunc i64 %indvars.iv.next to i32</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> %exitcond = icmp eq i32 %lftr.wideiv, %n</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> br i1 %exitcond, label %if.end.loopexit, label %for.body</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0);min-height:14px"><span style=""></span><br></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style="">if.end.loopexit: ; preds = %for.body</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> br label %if.end</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0);min-height:14px"><span style=""></span><br></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style="">if.end: ; preds = %if.end.loopexit, %entry</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style=""> ret void</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;color:rgb(77,186,43);background-color:rgb(0,0,0)"><span style="">}</span></p></div><div><br></div><div>Thanks,</div><div><br></div><div>Dong</div></div>