[PATCH] D75385: [TargetLowering] Avoid infinite iteration on setcc fold

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 15 10:57:02 PDT 2020


RKSimon added inline comments.


================
Comment at: llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp:2967
     // already a zero (otherwise, infinite loop).
     auto *YConst = dyn_cast<ConstantSDNode>(Y);
     if (YConst && YConst->isNullValue())
----------------
RKSimon wrote:
> greened wrote:
> > RKSimon wrote:
> > > Is this happening with vector cases, in which case would this work instead:
> > > 
> > > ConstantSDNode *YConst = isConstOrConstSplat(Y) ?
> > That would work for the case I saw.  But it seems prudent to guard against future constructs which might appear.  Anything that results in `Y` == `Zero` is going to cause an infinite loop.
> Under what circumstances will the isConstOrConstSplat + isNullValue() fail but the comparison against Zero work?
@greened - I'm not sure if you're still looking at this, but by inspection this should work. Any luck on creating a test case?
```
    ConstantSDNode *YConst =
        isConstOrConstSplat(Y, /*AllowUndefs*/ true, /*AllowTruncation*/ true);
    if (YConst && YConst->isNullValue())
      return SDValue();
    assert(Y != Zero && "Unknown zero value");
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75385





More information about the llvm-commits mailing list