[ConstantRange] Fix single bit abs range (PR59887)
authorNikita Popov <npopov@redhat.com>
Mon, 9 Jan 2023 15:29:37 +0000 (16:29 +0100)
committerNikita Popov <npopov@redhat.com>
Mon, 9 Jan 2023 15:34:09 +0000 (16:34 +0100)
commitfd07583ca439494891662d5db58895f63e904cc5
tree0aafc96e60c11420acf8b7dee36174d00213709c
parent835cf3ca6bee4b866488e08db1a2fd158a3ad086
[ConstantRange] Fix single bit abs range (PR59887)

For a full range input, we would produce an empty range instead
of a full range. The change to the SMin.isNonNegative() branch is
an optimality fix, because we should account for the potentially
discarded SMin value in the IntMinIsPoison case.

Change TestUnaryOpExhaustive to test both 4 and 1 bits, to both
cover this specific case in unit tests, and make sure all other
unary operations deal with 1-bit inputs correctly.

Fixes https://github.com/llvm/llvm-project/issues/59887.
llvm/lib/IR/ConstantRange.cpp
llvm/test/Transforms/CorrelatedValuePropagation/abs.ll
llvm/unittests/IR/ConstantRangeTest.cpp