[PATCH] D148413: [InstCombine] Remove requirement on `trunc` in `slt/sgt` case in `foldSelectICmpAndOr`

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 19 13:44:39 PDT 2023


goldstein.w.n marked an inline comment as done.
goldstein.w.n added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp:676
     C1Log = CmpLHS->getType()->getScalarSizeInBits() - 1;
     NeedAnd = true;
   }
----------------
goldstein.w.n wrote:
> nikic wrote:
> > Unless I'm missing something, we're missing an assignment to the `V` variable in this branch now? Also, do we still need the `NeedAnd`?
> > 
> > We should really just be using decomposeBitTestICmp() and a pow2 check I think, but this code is doing some very weird things I don't fully get.
> > Unless I'm missing something, we're missing an assignment to the `V` variable in this branch now? 
> 
> Good catch not sure how that didn't get caught in the tests.
> 
> >Also, do we still need the `NeedAnd`?
> 
> Yes. `x >= 0` == `x & SignBit == 0` but we don't have the actual `x & SignBit` expression.
> 
> > 
> > We should really just be using decomposeBitTestICmp() and a pow2 check I think, but this code is doing some very weird things I don't fully get.
> 
> I think that works. Will make it a follow up patch to this.
> Unless I'm missing something, we're missing an assignment to the `V` variable in this branch now? Also, do we still need the `NeedAnd`?
> 
Done.

> We should really just be using decomposeBitTestICmp() and a pow2 check I think, but this code is doing some very weird things I don't fully get.

See: D148744


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148413



More information about the llvm-commits mailing list