Bug 264984

Summary: [JSC] Refine B3 and masm tests for EXTR pattern detection and application
Product: WebKit Reporter: Yijia Huang <yijia_huang>
Component: JavaScriptCoreAssignee: Yijia Huang <yijia_huang>
Status: RESOLVED FIXED    
Severity: Normal CC: webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Description Yijia Huang 2023-11-16 14:59:15 PST
Also need to add these test cases.

--- a/Source/JavaScriptCore/b3/testb3_2.cpp
+++ b/Source/JavaScriptCore/b3/testb3_2.cpp
@@ -4883,7 +4883,7 @@ void testExtractRegister32()
 {
     if (JSC::Options::defaultB3OptLevel() < 2)
         return;    
-    Vector<uint32_t> lowWidths = { 0, 17, 31 };
+    Vector<uint32_t> lowWidths = { 0, 17, 31, 32 };
 
     // Test Pattern: ((n & mask1) << highWidth) | ((m & mask2) >> lowWidth)
     // Where: highWidth = datasize - lowWidth
@@ -4915,7 +4915,7 @@ void testExtractRegister32()
             root->appendNew<Value>(proc, BitOr, Origin(), left, right));
 
         auto code = compileProc(proc);
-        if (isARM64() && lowWidth > 0)
+        if (isARM64() && 0 < lowWidth && lowWidth < 32)
             checkUsesInstruction(*code, "extr");
         return invoke<uint32_t>(*code, n, m);
     };
@@ -4943,7 +4943,7 @@ void testExtractRegister64()
 {
     if (JSC::Options::defaultB3OptLevel() < 2)
         return;    
-    Vector<uint64_t> lowWidths = { 0, 34, 63 };
+    Vector<uint64_t> lowWidths = { 0, 34, 63, 64 };
 
     // Test Pattern: ((n & mask1) << highWidth) | ((m & mask2) >> lowWidth)
     // Where: highWidth = datasize - lowWidth
@@ -4971,7 +4971,7 @@ void testExtractRegister64()
             root->appendNew<Value>(proc, BitOr, Origin(), left, right));
 
         auto code = compileProc(proc);
-        if (isARM64() && lowWidth > 0)
+        if (isARM64() && 0 < lowWidth && lowWidth < 64)
             checkUsesInstruction(*code, "extr");
         return invoke<uint64_t>(*code, n, m);
     };
Comment 1 Radar WebKit Bug Importer 2023-11-16 14:59:59 PST
<rdar://problem/118532295>
Comment 2 Yijia Huang 2024-02-03 17:09:04 PST
Pull request: https://github.com/WebKit/WebKit/pull/23820
Comment 3 EWS 2024-02-06 09:24:14 PST
Committed 274149@main (084df28f4fc4): <https://commits.webkit.org/274149@main>

Reviewed commits have been landed. Closing PR #23820 and removing active labels.