<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:12pt">Hi Nick,<br><br>the problem was that I was compiling without any optimization. Now I could see some AddRecs. Thanks!<br><br><div><br><span></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><br><span></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><br><span></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><br><span></span></div><div style="color: rgb(0,
0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><span><br></span></div><div style="display: block;" class="yahoo_quoted"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 12pt;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 12pt;"> <div dir="ltr"> <font face="Arial" size="2"> On Tuesday, April 1, 2014 4:16 AM, Nick Lewycky <nicholas@mxc.ca> wrote:<br> </font> </div> <div class="y_msg_container">Beckert Frey wrote:<br clear="none">> Hello,<br clear="none">><br clear="none">> I'm studying how the SCEV analyzis works and how to use it and I could<br clear="none">> not create an example where the SCEV analyzis identifies an expression<br clear="none">> as "SCEVAddRecExpr".<br clear="none">><br
clear="none">> Aren't the expressions below the kind of pattern that should be<br clear="none">> represented as a "AddRecExpr" ?<br clear="none">><br clear="none">> SCEV: (1 + (2 * %3)<br clear="none">> or<br clear="none">> SCEV: (%1 + (2 * %3)<br clear="none">> or<br clear="none">> SCEV: (%1 + (%2 * %3)<br clear="none"><br clear="none">You want a PHI node. It's not an add recurrence unless it's making a <br clear="none">trip around the loop.<br clear="none"><br clear="none">Take a look at test/Analysis/ScalarEvolution/trip-count.ll :<br clear="none"><br clear="none">$ opt -analyze -scalar-evolution trip-count.ll<br clear="none">Printing analysis 'Scalar Evolution Analysis' for function 'test':<br clear="none">Classifying expressions for: @test<br clear="none"> %tmp = getelementptr [1000 x i32]* @A, i32 0, i32 %i.0<br clear="none"> --> {@A,+,sizeof(i32)}<%bb3> Exits:
((10000 * sizeof(i32)) + @A)<br clear="none"> %tmp2 = add i32 %i.0, 1<br clear="none"> --> {1,+,1}<nw><%bb3> Exits: 10001<br clear="none"> %i.0 = phi i32 [ 0, %entry ], [ %tmp2, %bb ]<br clear="none"> --> {0,+,1}<nuw><%bb3> Exits: 10000<br clear="none">Determining loop execution counts for: @test<br clear="none">Loop %bb3: backedge-taken count is 10000<br clear="none">Loop %bb3: max backedge-taken count is 10000<div class="yqt5914289082" id="yqtfd25071"><br clear="none"><br clear="none"><br clear="none">> In my experiments they are always recognized as just "AddExpr" (not<br clear="none">> *Rec*). Can someone help me on this? What I'm misunderstanding here?<br clear="none">><br clear="none">> I'm using the attached code to perform my experiments and this example<br
clear="none">> as test input:<br clear="none">><br clear="none">> int main() {<br clear="none">> int vet1[100], i=0;<br clear="none">><br clear="none">> for (i=0; i<10; i++) {<br clear="none">> vet1[3*i + 2] = vet1[i];<br clear="none">> }<br clear="none">><br clear="none">> return 0;</div><br clear="none">> }<br clear="none"><br clear="none">Remember that SCEV runs on IR not C. If you want to discuss what C code <br clear="none">you're running SCEV over, we need to talk about how you've transformed <br clear="none">this C into IR. For instance, if you built that with clang -O0 then ran <br clear="none">SCEV over that it won't work at all because SCEV assumes some basic <br clear="none">optimizations have already been performed (ie., it works on <br clear="none">canonicalized IR and doesn't try to replicate the work of other <br clear="none">optimizations. That would be outside its scope.)<br clear="none"><br
clear="none">Nick<div class="yqt5914289082" id="yqtfd37968"><br clear="none"></div><br><br></div> </div> </div> </div> </div></body></html>