Patch forthcoming.

Created attachment 270286 [details] the patch

Comment on attachment 270286 [details] the patch View in context: https://bugs.webkit.org/attachment.cgi?id=270286&action=review R=me > Source/JavaScriptCore/b3/B3ReduceStrength.cpp:726 > + m_changed = true; This indentation looks off to me (but I'm on my phone so maybe not) > Source/JavaScriptCore/b3/B3ReduceStrength.cpp:762 > + // This does work for the D = -1 special case. Why not turn D=-1 and D=1 into 0 as the result? > Source/JavaScriptCore/b3/B3ReduceStrength.cpp:764 > + // = -2^31 - -2^31 * -1 This should be: -2^31 - (2^31 * -1)

(In reply to comment #2) > Comment on attachment 270286 [details] > the patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=270286&action=review > > R=me > > > Source/JavaScriptCore/b3/B3ReduceStrength.cpp:726 > > + m_changed = true; > > This indentation looks off to me (but I'm on my phone so maybe not) > > > Source/JavaScriptCore/b3/B3ReduceStrength.cpp:762 > > + // This does work for the D = -1 special case. > > Why not turn D=-1 and D=1 into 0 as the result? Because I didn't know if that was correct. I guess it is. We already get this optimization since we have Sub(N,Mul(Div(N,1),1)) which reduces to Sub(N,Mul(N,1)) then Sub(N,N) and then 0. Unless the strength reduction phase becomes very expensive, it's sort of nice that it handles a lot of things by induction. > > > Source/JavaScriptCore/b3/B3ReduceStrength.cpp:764 > > + // = -2^31 - -2^31 * -1 > > This should be: > -2^31 - (2^31 * -1) I really did mean "-2^31 - ((-(2^31)) * -1)". Is it not clear that this is what is meant from how I wrote it?

Landed in http://trac.webkit.org/changeset/195882

Comment on attachment 270286 [details] the patch View in context: https://bugs.webkit.org/attachment.cgi?id=270286&action=review >>> Source/JavaScriptCore/b3/B3ReduceStrength.cpp:764 >>> + // = -2^31 - -2^31 * -1 >> >> This should be: >> -2^31 - (2^31 * -1) > > I really did mean "-2^31 - ((-(2^31)) * -1)". Is it not clear that this is what is meant from how I wrote it? I understood your notation, but the calculation you wrote is incorrect: -(2^31) - (-2^31 * -1) = -(2^31) - (2^31) = -2^32 because -2^31 - -2^31 / -1 * -1 !== -(2^31) - (-2^31 * -1) it is -2^31 - -2^31 / -1 * -1 = -2^31 - (2^31 * -1) = -2^31 - (-2^31) = -2^31 + 2^31 = 0

(In reply to comment #5) > Comment on attachment 270286 [details] > the patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=270286&action=review > > >>> Source/JavaScriptCore/b3/B3ReduceStrength.cpp:764 > >>> + // = -2^31 - -2^31 * -1 > >> > >> This should be: > >> -2^31 - (2^31 * -1) > > > > I really did mean "-2^31 - ((-(2^31)) * -1)". Is it not clear that this is what is meant from how I wrote it? > > I understood your notation, but the calculation you wrote is incorrect: > -(2^31) - (-2^31 * -1) = -(2^31) - (2^31) = -2^32 > because > -2^31 - -2^31 / -1 * -1 !== -(2^31) - (-2^31 * -1) > it is > -2^31 - -2^31 / -1 * -1 = -2^31 - (2^31 * -1) = -2^31 - (-2^31) = -2^31 + > 2^31 = 0 This is int32 math. In int32 math, -1 * -2^31 = -2*31.

(In reply to comment #6) > (In reply to comment #5) > > Comment on attachment 270286 [details] > > the patch > > > > View in context: > > https://bugs.webkit.org/attachment.cgi?id=270286&action=review > > > > >>> Source/JavaScriptCore/b3/B3ReduceStrength.cpp:764 > > >>> + // = -2^31 - -2^31 * -1 > > >> > > >> This should be: > > >> -2^31 - (2^31 * -1) > > > > > > I really did mean "-2^31 - ((-(2^31)) * -1)". Is it not clear that this is what is meant from how I wrote it? > > > > I understood your notation, but the calculation you wrote is incorrect: > > -(2^31) - (-2^31 * -1) = -(2^31) - (2^31) = -2^32 > > because > > -2^31 - -2^31 / -1 * -1 !== -(2^31) - (-2^31 * -1) > > it is > > -2^31 - -2^31 / -1 * -1 = -2^31 - (2^31 * -1) = -2^31 - (-2^31) = -2^31 + > > 2^31 = 0 > > This is int32 math. In int32 math, -1 * -2^31 = -2*31. Also -2^31 / -1 = -2^31. And 0 - -2^31 = -2^31. And -(-2^31) = -2^31.