InstCombine tries to rewrite
%prod = mul nsw i64 %X, Scale %acc = add nsw i64 %prod, Offset %0 = alloca i8, i64 %acc, align 4 %1 = bitcast i8* %0 to i32* Use ( %1 )
into
%prod = mul nsw i64 %X, Scale/4 %acc = add nsw i64 %prod, Offset/4 %0 = alloca i32, i64 %acc, align 4 Use (%0)
But it assumes Scale is unsigned.
For now, bail out on negative operands to avoid an incorrect transformation.
Isn't the actual bug here? The && !OBI->hasNoSignedWrap() shouldn't be there. The number of elements is an unsigned value, so we should be checking for no unsigned wrap, not "either no unsigned or no signed wrap".