[LLVMdev] A simple case about SDiv

Zhou Sheng zhousheng00 at gmail.com
Thu Sep 4 08:31:44 PDT 2008


Hi,

I have a simple C case as following:

int test(int x, int y) {
  return -x / -y;
}

With llvm-gcc -O1, I got:

define i32 @test(i32 %x, i32 %y) nounwind {
entry:
  sub i32 0, %x ; <i32>:0 [#uses=1]
  sub i32 0, %y ; <i32>:1 [#uses=1]
  sdiv i32 %0, %1 ; <i32>:2 [#uses=1]
  ret i32 %2
}

With llvm-gcc -O2, I got:

define i32 @test(i32 %x, i32 %y) nounwind {
entry:
  sdiv i32 %x, %y ; <i32>:0 [#uses=1]
  ret i32 %0
}

I wonder which pass does this transform.

I tried several passes, like -instcombine, -simplifycfg, -gcse -globaldce
-globalopt -adce , but all failed to do this transform.

Anybody know this? Thanks.

Sheng.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080904/e0428101/attachment.html>


More information about the llvm-dev mailing list