Hi all,<div><br></div><div>I want to use scalarrepl pass to eliminate the allocation of mat_alloc which is of type [4 x <4 x float>] in the following program. </div><div><br></div><div>$cat test.ll</div><div><br></div>

<div><div>; ModuleID = 'test.ll'</div></div><div><br></div><div>define void @main(<4 x float>* %inArg, <4 x float>* %outArg, [4 x <4 x float>]* %constants) nounwind {</div><div>entry:</div><div>
  %inArg1 = load <4 x float>* %inArg</div>
<div>  %mat_alloc = alloca [4 x <4 x float>]</div><div>  %matVal = load [4 x <4 x float>]* %constants</div><div>  store [4 x <4 x float>] %matVal, [4 x <4 x float>]* %mat_alloc</div><div>  %0 = getelementptr inbounds [4 x <4 x float>]* %mat_alloc, i32 0, i32 0</div>

<div>  %1 = load <4 x float>* %0</div><div>  %2 = fmul <4 x float> %1, %inArg1</div><div>  %3 = getelementptr inbounds [4 x <4 x float>]* %mat_alloc, i32 0, i32 1</div><div>  %4 = load <4 x float>* %3</div>

<div>  %5 = fmul <4 x float> %4, %inArg1</div><div>  %6 = fadd <4 x float> %2, %5</div><div>  %7 = getelementptr inbounds [4 x <4 x float>]* %mat_alloc, i32 0, i32 2</div><div>  %8 = load <4 x float>* %7</div>

<div>  %9 = fmul <4 x float> %8, %inArg1</div><div>  %10 = fadd <4 x float> %6, %9</div><div>  %11 = getelementptr inbounds [4 x <4 x float>]* %mat_alloc, i32 0, i32 3</div><div>  %12 = load <4 x float>* %11</div>

<div>  %13 = fadd <4 x float> %10, %12</div><div>  %14 = getelementptr <4 x float>* %outArg, i32 1</div><div>  store <4 x float> %13, <4 x float>* %14</div><div>  ret void</div><div>} </div><div><br>

</div><div><div>$ opt -S -stats -scalarrepl test.ll </div></div><div><br></div><div>No transformation is performed. I've examined the source code of scalarrepl. It seems this pass does not handle array allocations. Is there other transformation pass I can use to eliminate this allocation?</div>

<div><br></div><div>Thanks,</div><div>David</div><div><br></div>