[PATCH] D84792: [InstSimplify/NewGVN] Add option to control the use of undef.

Juneyoung Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 28 18:20:20 PDT 2020


aqjune added a comment.

I'm afraid that adding Q.CanUseUndef to the places where isa<UndefValue> is used isn't enough; equality (`==`) can implicitly fold undef since UndefValue is singleton.

For example, given `icmp eq X, Y`, if X and Y are both UndefValue, comparison X == Y will yield true. This will trigger this transformation even if `Q.CanUseUndef` was false:

  // icmp X, X -> true/false
  // icmp X, undef -> true/false because undef could be X.
  if (LHS == RHS || (Q.CanUseUndef && isa<UndefValue>(RHS)))
    return ConstantInt::get(ITy, CmpInst::isTrueWhenEqual(Pred));

However, in theory, this is also using one of the two undefs by constraining it to have a value that is equal to another undef.

I'm just brainstorming, what if there is a pass that removes all undefs from a function by folding them away? If there is no undef, bad undef foldings will never happen trivially. InstSimplify may create undefs on-the-fly again, but making InstSimplify never create undef will be easier.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84792



More information about the llvm-commits mailing list