value tracking

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

value tracking

Xin Tong-3
I would like to know what API i can use to tell that x cant be negative. I looked through the value tracking analysis API, nothing seems immediate.

int divBy4(int x) {
  if (x < 0) abort();
  return x/4; 
} 


Thanks,
Trent

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: value tracking

陳韋任
Hi Xin Tong,

On Thu, Feb 5, 2015 at 7:46 AM, Xin Tong <[hidden email]> wrote:

> I would like to know what API i can use to tell that x cant be negative. I
> looked through the value tracking analysis API, nothing seems immediate.
>
> int divBy4(int x) {
>   if (x < 0) abort();
>   return x/4;
>
> }
>
> http://llvm.org/docs/doxygen/html/ValueTracking_8h.html

  How about llvm::ComputeSignBit? I think you can tell it's negative
by the sign bit, right?

Regards,
chenwj
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev