Skip to content

Value Range: clang cannot know (a >> 3 == -2) means a in [ -16, -9] #75613

Closed
@k-arrows

Description

@k-arrows

Test case:
https://godbolt.org/z/daYcYhxad

bool foo(int a)
{
  if ((a >> 3) + 2 == 0) return true;
  else return (a < -16 || a > -9);
}

Some generalizations will be necessary, but this is motivated from the following gcc testsuite:
https://github.com/gcc-mirror/gcc/blob/master/gcc/testsuite/gcc.dg/tree-ssa/vrp76.c

Clang13 can optimize the above function foo, but it cannot the original f3. Therefore, there may be problems that differ from the value range. Sorry if my example is inappropriate.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions