[all-commits] [llvm/llvm-project] 0be0a1: [ValueTracking] improve analysis for "C << X" and ...

RotateRight via All-commits all-commits at lists.llvm.org
Tue Feb 9 09:56:57 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0be0a1237cb9d9a0228cf27dacfcd0b95749d7ee
      https://github.com/llvm/llvm-project/commit/0be0a1237cb9d9a0228cf27dacfcd0b95749d7ee
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2021-02-09 (Tue, 09 Feb 2021)

  Changed paths:
    M llvm/lib/Analysis/ValueTracking.cpp
    M llvm/test/Transforms/InstCombine/and2.ll
    M llvm/test/Transforms/InstCombine/lshr-and-negC-icmpeq-zero.ll
    M llvm/test/Transforms/InstCombine/shift.ll
    M llvm/test/Transforms/InstCombine/signbit-shl-and-icmpeq-zero.ll
    M llvm/test/Transforms/InstCombine/zext-or-icmp.ll

  Log Message:
  -----------
  [ValueTracking] improve analysis for "C << X" and "C >> X"

This is based on the example/comments in:
https://llvm.org/PR48984

I tried just lifting the restriction in computeKnownBitsFromShiftOperator()
as suggested in the bug report, but that doesn't catch all of the cases
shown here. I didn't step through to see exactly why that happened. But it
seems like a reasonable compromise to cheaply check the special-case of
shifting a constant.

There's a slight regression on a cmp transform as noted, but this is likely
the more important/common pattern, so we can fix that icmp pattern later if
needed.

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




More information about the All-commits mailing list