B3 should reduce Shl(<S|Z>Shr(@x, @const), @const) to BitAnd(@x, -(1<<@const))
authorrmorisset@apple.com <rmorisset@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 Mar 2019 15:29:10 +0000 (15:29 +0000)
committerrmorisset@apple.com <rmorisset@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 Mar 2019 15:29:10 +0000 (15:29 +0000)
commit23d560e460631401438228808687281d33337995
treee75c17bd5d6d7612d1bee7a9556a37d5535b27f5
parentb033d009aee9cf96fa2b4d07dd96b55d106321ab
B3 should reduce Shl(<S|Z>Shr(@x, @const), @const) to BitAnd(@x, -(1<<@const))
https://bugs.webkit.org/show_bug.cgi?id=152164

Reviewed by Filip Pizlo.

Turn this: Shl(<S|Z>Shr(@x, @const), @const)
Into this: BitAnd(@x, -(1<<@const))

I added two tests: one for ZShr/32 bits, and one for SShr/64 bits, I think it is enough coverage (no reason for any interaction between the signedness of the shift and the bitwidth).
I also modified a few adjacent tests to remove undefined behaviours.

* b3/B3ReduceStrength.cpp:
* b3/testb3.cpp:
(JSC::B3::testShlImms):
(JSC::B3::testShlArgImm):
(JSC::B3::testShlSShrArgImm):
(JSC::B3::testShlImms32):
(JSC::B3::testShlArgImm32):
(JSC::B3::testShlZShrArgImm32):
(JSC::B3::run):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243065 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/b3/B3ReduceStrength.cpp
Source/JavaScriptCore/b3/testb3.cpp