[llvm] [DA] Widening SCEV expressions in strong SIV test to prevent overflow (PR #164704)
    Ehsan Amiri via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Fri Oct 24 06:18:55 PDT 2025
    
    
  
amehsan wrote:
> > But isn't that isKnownPredicate always going to fail in the case where the multiply may overflow? That means that the value is potentially larger than the original type, and AbsDelta fits within that type. Maybe I'm misunderstanding something here.
> 
> I generally agree with this. Maybe the one mistake here is that `AbsDelta` is (the absolute value of) the result of subtracting two values (`SrcConst - DstConst`), so it may also exceed the bounds of the original type. However, for `isKnownPredicate` being true when the multiply _may_ overflow, perhaps we need to ensure that the subtraction _must_ overflow so that AbsDelta is guaranteed to be larger than the original type. I think this is a very rare case.
 If operands are multiply are 64 bit values that are sign-extended to 128 bit then the product trivially won't overflow 128-bit computation. I don't see what is the issue being discussed here. To do the comparison we extend either subtraction result or subtraction operands to 128 bits.
That said, there was  probably a misinterpretation of the some examples on our side. While the idea is correct, we don't see clear advantage on it over simpler check of nsw flag over multiply (and probably some other safeguards) , at least for SIV. 
@1997alireza can change this patch to implement the simpler solution. We can check if the idea is useful for other tests or not.
https://github.com/llvm/llvm-project/pull/164704
    
    
More information about the llvm-commits
mailing list