[PATCH] D54237: Constant folding and instcombine for saturating adds
    Nuno Lopes via Phabricator via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Thu Nov  8 14:41:59 PST 2018
    
    
  
nlopes added a comment.
In https://reviews.llvm.org/D54237#1291405, @nikic wrote:
> Regarding
>
>   // X + undef -> undef
>   // undef + X -> undef
>   if (match(Op1, m_Undef()) || match(Op0, m_Undef()))
>     return UndefValue::get(ReturnType);
>   
>
> I was initially planning to include these simplifications, but ultimately was not certain regarding their legality. In particular, if we have uadd.sat(MaxValue, Y), then the result is fully determined to be MaxValue, regardless of the value of Y. If we have something like sadd.sat(SignedMinValue, Y) then the result is known to be negative. In either case the intrinsic cannot have the full range of results of the result type, regardless of the value of Y. As such, I think folding operations on undef to undef would not be legal in this case.
>
> It should be possible to fold uadd.sat(X, undef) to MaxValue. Not sure how useful that is though.
You can also assume that undef is 0 and fold X + undef -> X.
https://reviews.llvm.org/D54237
    
    
More information about the llvm-commits
mailing list