nuw, nsw flags for SCEVAdd and SCEVMul

Hi,

I found out that we do not have nuw and nsw flags for some situations. I ran test cases with range metadata: !2 = !{i16 0, i16 128}

And I get nuw, nsw flags for

%A = add i16 %x, 2
→ (2 + %x) U: [2,130) S: [2,130)

But for below cases, there are no nuw or nsw flags shown.

%A = add i16 %x, %x
→ (2 * %x) U: [0,255) S: [0,255)

%A = mul i16 %x, 2
→ (2 * %x) U: [0,255) S: [0,255)

%A = mul i16 %x, %x
→ (%x * %x) U: [0,16130) S: [0,16130)

From the range we calculated here. Can’t we have the flags?

And for instructions with nuw, I still did not get those flags.

%A = mul nuw i16 %x, %x
→ (%x * %x) U: [0,16130) S: [0,16130)

%A = add nuw i16 %x, %x
→ (2 * %x) U: [0,255) S: [0,255)

Are there any reasons for this behavior? Or is it okay to have those flags for cases mentioned above?

Thanks,
Lin-Ya

I think what you suggest would be a correct enhancement to SCEV, but I
thought Tim [CCed] already fixed this in
https://reviews.llvm.org/rL336140.

-- Sanjoy