<div dir="ltr"><p>Hi,<br></p><p>I have a simple C case as following:</p><p>int test(int x, int y) {<br> return -x / -y;<br>}</p><p>With llvm-gcc -O1, I got:</p><p>define i32 @test(i32 %x, i32 %y) nounwind {<br>entry:<br> sub i32 0, %x ; <i32>:0 [#uses=1]<br>
sub i32 0, %y ; <i32>:1 [#uses=1]<br> sdiv i32 %0, %1 ; <i32>:2 [#uses=1]<br> ret i32 %2<br>}<br><br>With llvm-gcc -O2, I got:<br></p><p>define i32 @test(i32 %x, i32 %y) nounwind {<br>entry:<br>
sdiv i32 %x, %y ; <i32>:0 [#uses=1]<br> ret i32 %0<br>}</p><p></p><p>I wonder which pass does this transform.</p><p>I tried several passes, like -instcombine, -simplifycfg, -gcse -globaldce -globalopt -adce , but all failed to do this transform.</p>
<p>Anybody know this? Thanks.</p><p></p><p>Sheng.<br><br></p></div>