[LoopIdiomRecognize] Only convert loops to ctlz if we can prove that the input is non-negative.

Summary:

Loop idiom recognize tries to convert loops like

int foo(int x) { int cnt = 0; while (x) { x >>= 1; ++cnt; } return cnt; }

into calls to ctlz, but if x is initially negative this loop should be infinite.

It happens that the cases that motivated this change have an absolute value of x before the loop. So this patch restricts the transform to cases where we know x is positive. Note: We are relying on the absolute value of INT_MIN to be undefined so we can assume that the result is always positive.

Fixes PR37479

Reviewers: spatel, hfinkel, efriedma, javed.absar

Reviewed By: efriedma

Subscribers: dmgreen, llvm-commits

Differential Revision: https://reviews.llvm.org/D47348

llvm-svn: 333702