intTest(inta)=>1000/b;// same for 'C % b'
Current arm64 codegen:
G_M17171_IG01: A9BF7BFD stp fp, lr,[sp,#-16]! 910003FD mov fp,spG_M17171_IG02: 52807D00 mov w0, #0x3e8 7100005F cmp w2, #054000140 beq G_M17171_IG06 3100045F cmn w2, #154000081 bne G_M17171_IG03 2B00001F adds wzr, w0, w054000041 bne G_M17171_IG03 ; <-- btw, two subsequent jumps?? 54000086 bvs G_M17171_IG05G_M17171_IG03: 1AC20C00 sdiv w0, w0, w2G_M17171_IG04: A8C17BFD ldp fp, lr,[sp],#16 D65F03C0 ret lrG_M17171_IG05: 94000000bl CORINFO_HELP_OVERFLOWG_M17171_IG06: 94000000bl CORINFO_HELP_THROWDIVZERO D43E0000 bkpt; Total bytes of code 64
As far as I understand overflow can only happen if we divide int.MinValue by -1 so it's not the case for C / x where C is not int.MinValue
Also, GT_ARRLEN can't be -1 and int.MinValue so e.g. array.Length % x or x % array.Length shouldn't produce any overflow checks as well.
category:cq
theme:div-mod-rem
skill-level:intermediate
cost:medium
impact:medium
Current arm64 codegen:
As far as I understand overflow can only happen if we divide
int.MinValueby-1so it's not the case forC / xwhereCis notint.MinValueAlso,
GT_ARRLENcan't be-1andint.MinValueso e.g.array.Length % xorx % array.Lengthshouldn't produce any overflow checks as well.category:cq
theme:div-mod-rem
skill-level:intermediate
cost:medium
impact:medium