[PATCH] D142546: [ConstraintElimination] Decompose or instruction if the constant operand < 2^known_zero_bits of the first operand.

Zain Jaffal via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 26 03:23:46 PST 2023


zjaffal added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/ConstraintElimination.cpp:351
+  if (match(V, m_Or(m_Value(Op0), m_ConstantInt(CI)))) {
+    auto KnownBits = computeKnownBits(Op0, DL, MaxAnalysisRecursionDepth - 1);
+    if (CI->getZExtValue() < pow(2, KnownBits.Zero.getZExtValue()))
----------------
nikic wrote:
> You're looking for haveNoCommonBitsSet().
I tried the following snippet 
```
if (match(V, m_Or(m_Value(Op0), m_ConstantInt(CI)))) {
  if (haveNoCommonBitsSet(Op0, CI, DL))
    return MergeResults(Op0, CI, IsSigned);
}
```
it works for most of the cases but for the following test `define void @test.not.uge.ule` 
```
%start.4 = or i8 %start, 4
%t.4 = icmp ule i8 %start.4, %high
call void @use(i1 %t.4)
```
`%t.4` is not replaced with true


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142546



More information about the llvm-commits mailing list