[PATCH] D142271: [ValueTracking] Add KnownBits patterns `xor(x, x - 1)` and `and(x, -x)` for knowing upper bits to be zero

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 23 17:44:35 PST 2023


goldstein.w.n added inline comments.


================
Comment at: llvm/test/Transforms/InstCombine/ctpop-pow2.ll:150
+; CHECK-NEXT:    [[AND:%.*]] = and <2 x i32> [[X1]], [[SUB]]
+; CHECK-NEXT:    ret <2 x i32> [[AND]]
 ;
----------------
This regression is fixed in: https://reviews.llvm.org/D142429

What is happening is `computeKnownBits` is allowing `instsimplify` to optimize out the `ctpop` b.c its `ctpop(x & 1)`, but since `SimplifyDemandedUseBits` doesn't have this logic yet, it never gets optimized out. `D142429` starts using `computeKnownBits` in `SimplifyDemandedUseBits` which fixed this.



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142271/new/

https://reviews.llvm.org/D142271



More information about the llvm-commits mailing list