[InstCombine] Fold sdiv exact X, -1<<C --> -(ashr exact X, C)
While that does increases instruction count, shift is obviously better than a division. Name: base Pre: (1<<C1) >= 0 %o0 = shl i8 1, C1 %r = sdiv exact i8 C0, %o0 => %r = ashr exact i8 C0, C1 Name: neg %o0 = shl i8 -1, C1 %r = sdiv exact i8 C0, %o0 => %t0 = ashr exact i8 C0, C1 %r = sub i8 0, %t0 Name: reverse Pre: C1 != 0 && C1 u< 8 %t0 = ashr exact i8 C0, C1 %r = sub i8 0, %t0 => %o0 = shl i8 -1, C1 %r = sdiv exact i8 C0, %o0 https://rise4fun.com/Alive/MRplf
Loading
Please sign in to comment