[all-commits] [llvm/llvm-project] c8a282: [GlobalISel] Fix computing known bits for loads wi...

Jessica Paquette via All-commits all-commits at lists.llvm.org
Thu Aug 6 16:50:28 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: c8a282bcf7b6304e99f65bf22eea4553e240fb40
      https://github.com/llvm/llvm-project/commit/c8a282bcf7b6304e99f65bf22eea4553e240fb40
  Author: Jessica Paquette <jpaquette at apple.com>
  Date:   2020-08-06 (Thu, 06 Aug 2020)

  Changed paths:
    M llvm/lib/Analysis/ValueTracking.cpp
    M llvm/unittests/CodeGen/GlobalISel/KnownBitsTest.cpp

  Log Message:
  -----------
  [GlobalISel] Fix computing known bits for loads with range metadata

In GlobalISel, if you have a load into a small type with a range, you'll hit
an assert if you try to compute known bits on it starting at a larger type.

e.g.

```
%x:_(s8) = G_LOAD %whatever(p0) :: (load 1 ... !range !n)
...
%y:_(s32) = G_SOMETHING %x
```

When we walk through G_SOMETHING and hit the load, the width of our known bits
is 32. However, the width of the range is going to be 8. This will cause us
to hit an assert.

To fix this, make computeKnownBitsFromRangeMetadata zero extend or truncate
the range type to match the bitwidth of the known bits we're calculating.

Add a testcase in CodeGen/GlobalISel/KnownBitsTest.cpp to reflect that this
works now.

https://reviews.llvm.org/D85375




More information about the All-commits mailing list