<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hi,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Not sure what you mean by only getting binaries: "clang -S -emit-llvm" should produce a .ll and so will opt. </div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
> clang  -S -emit-llvm find_max.c -o find_max.ll</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Since no optimisation level is specified, this will result in very unoptimised code, probably resulting in vectorisation not triggering. I usually do "clang -O3 -S -emit-llvm -mllvm -print-before-all", or something equivalent, and then grab the IR just before
 vectorisation. </div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
> clang -O3 -c find_max.c -Rpass=vector -Rpass-analysis=vector</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
>From a very quick look, this will probably not show anything because of your example: the second loop has no effect and is optimised away, only the first remains which is fully unrolled. Returning "max" will probably help.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> llvm-dev <llvm-dev-bounces@lists.llvm.org> on behalf of Sudakshina Dutta via llvm-dev <llvm-dev@lists.llvm.org><br>
<b>Sent:</b> 14 May 2021 04:16<br>
<b>To:</b> LLVM Development List <llvm-dev@lists.llvm.org><br>
<b>Subject:</b> [llvm-dev] Auto-vectorization option</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div>Dear all,</div>
<div><br>
</div>
<div>Greetings. I want to generate the intermediate code (.ll file) after having LLVM auto-vectorization transformation on the source C file. I have the following code  (find_max.c) on which I want to apply auto-vectorization.<br>
</div>
<div><br>
</div>
<div>int main()<br>
{<br>
    int i, n, max, arr[50];<br>
    for(i = 0; i < 35; i++)<br>
    {<br>
        printf("arr[%d] = ", i);<br>
        scanf("%d", &arr[i]);<br>
    }<br>
    max = arr[0];<br>
    for(i = 1; i < 35; i++)<br>
    {<br>
        if(arr[i] > max)<br>
        {<br>
            max = arr[i];<br>
        }<br>
    }<br>
<br>
}</div>
<div><br>
</div>
<div>I have tried the following.</div>
<div><br>
</div>
<div>
<ol>
<li>clang  -S -emit-llvm find_max.c -o find_max.ll</li><li>opt -loop-vectorize -force-vector-width=8 find_max.ll -o find_max_opt.ll<br>
</li></ol>
</div>
<div>and<br>
</div>
<div>
<ol>
<li>clang -O3 -c find_max.c -Rpass=vector -Rpass-analysis=vector</li><li>clang -O3 -c find_max.c -Rpass=vector -Rpass-analysis=vector -o find_max.ll</li></ol>
<div><br>
</div>
<div>All the above options generate binary files. I request you to please help.</div>
<div><br>
</div>
<div>Thanks and regards,</div>
<div>Sudakshina<br>
</div>
</div>
</div>
</div>
</body>
</html>