Changeset 247390 in webkit
- Timestamp:
- Jul 12, 2019 10:11:31 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r247387 r247390 1 2019-07-12 Justin Michaud <justin_michaud@apple.com> 2 3 B3 should reduce (integer) Sub(Neg(x), y) to Neg(Add(x, y)) 4 https://bugs.webkit.org/show_bug.cgi?id=196371 5 6 Reviewed by Keith Miller. 7 8 * microbenchmarks/mul-immediate-sub.js: Added. 9 (doTest): 10 1 11 2019-07-12 Caio Lima <ticaiolima@gmail.com> 2 12 -
trunk/Source/JavaScriptCore/ChangeLog
r247387 r247390 1 2019-07-12 Justin Michaud <justin_michaud@apple.com> 2 3 B3 should reduce (integer) Sub(Neg(x), y) to Neg(Add(x, y)) 4 https://bugs.webkit.org/show_bug.cgi?id=196371 5 6 Reviewed by Keith Miller. 7 8 Adding these strength reductions gives 2x a (x86) and 3x (arm64) performance improvement 9 on the microbenchmark. 10 11 * b3/B3ReduceStrength.cpp: 12 * b3/testb3.cpp: 13 (JSC::B3::testSubSub): 14 (JSC::B3::testSubSub2): 15 (JSC::B3::testSubAdd): 16 (JSC::B3::testSubFirstNeg): 17 (JSC::B3::run): 18 1 19 2019-07-12 Caio Lima <ticaiolima@gmail.com> 2 20 -
trunk/Source/JavaScriptCore/b3/B3ReduceStrength.cpp
r245192 r247390 649 649 if (m_value->child(1)->opcode() == Neg) { 650 650 replaceWithNew<Value>(Add, m_value->origin(), m_value->child(0), m_value->child(1)->child(0)); 651 break; 652 } 653 654 // Turn this: Sub(Neg(value), value2) 655 // Into this: Neg(Add(value, value2)) 656 if (m_value->child(0)->opcode() == Neg) { 657 replaceWithNew<Value>(Neg, m_value->origin(), 658 m_insertionSet.insert<Value>(m_index, Add, m_value->origin(), m_value->child(0)->child(0), m_value->child(1))); 659 break; 660 } 661 662 // Turn this: Sub(Sub(a, b), c) 663 // Into this: Sub(a, Add(b, c)) 664 if (m_value->child(0)->opcode() == Sub) { 665 replaceWithNew<Value>(Sub, m_value->origin(), m_value->child(0)->child(0), 666 m_insertionSet.insert<Value>(m_index, Add, m_value->origin(), m_value->child(0)->child(1), m_value->child(1))); 667 break; 668 } 669 670 // Turn this: Sub(a, Sub(b, c)) 671 // Into this: Add(Sub(a, b), c) 672 if (m_value->child(1)->opcode() == Sub) { 673 replaceWithNew<Value>(Add, m_value->origin(), 674 m_insertionSet.insert<Value>(m_index, Sub, m_value->origin(), m_value->child(0), m_value->child(1)->child(0)), 675 m_value->child(1)->child(1)); 676 break; 677 } 678 679 // Turn this: Sub(Add(a, b), c) 680 // Into this: Add(a, Sub(b, c)) 681 if (m_value->child(0)->opcode() == Add) { 682 replaceWithNew<Value>(Add, m_value->origin(), m_value->child(0)->child(0), 683 m_insertionSet.insert<Value>(m_index, Sub, m_value->origin(), m_value->child(0)->child(1), m_value->child(1))); 651 684 break; 652 685 } -
trunk/Source/JavaScriptCore/b3/testb3.cpp
r247363 r247390 2189 2189 root->appendNewControlValue(proc, Return, Origin(), negArgumentMinusOne); 2190 2190 CHECK(compileAndRun<int>(proc, a) == -a - 1); 2191 } 2192 2193 void testSubSub(int a, int b, int c) 2194 { 2195 Procedure proc; 2196 BasicBlock* root = proc.addBlock(); 2197 root->appendNewControlValue( 2198 proc, Return, Origin(), 2199 root->appendNew<Value>( 2200 proc, Sub, Origin(), 2201 root->appendNew<Value>(proc, Sub, Origin(), 2202 root->appendNew<ArgumentRegValue>(proc, Origin(), GPRInfo::argumentGPR0), 2203 root->appendNew<ArgumentRegValue>(proc, Origin(), GPRInfo::argumentGPR1)), 2204 root->appendNew<ArgumentRegValue>(proc, Origin(), GPRInfo::argumentGPR2))); 2205 2206 CHECK(compileAndRun<int>(proc, a, b, c) == (a-b)-c); 2207 } 2208 2209 void testSubSub2(int a, int b, int c) 2210 { 2211 Procedure proc; 2212 BasicBlock* root = proc.addBlock(); 2213 root->appendNewControlValue( 2214 proc, Return, Origin(), 2215 root->appendNew<Value>( 2216 proc, Sub, Origin(), 2217 root->appendNew<ArgumentRegValue>(proc, Origin(), GPRInfo::argumentGPR0), 2218 root->appendNew<Value>(proc, Sub, Origin(), 2219 root->appendNew<ArgumentRegValue>(proc, Origin(), GPRInfo::argumentGPR1), 2220 root->appendNew<ArgumentRegValue>(proc, Origin(), GPRInfo::argumentGPR2)))); 2221 2222 CHECK(compileAndRun<int>(proc, a, b, c) == a-(b-c)); 2223 } 2224 2225 void testSubAdd(int a, int b, int c) 2226 { 2227 Procedure proc; 2228 BasicBlock* root = proc.addBlock(); 2229 root->appendNewControlValue( 2230 proc, Return, Origin(), 2231 root->appendNew<Value>( 2232 proc, Sub, Origin(), 2233 root->appendNew<Value>(proc, Add, Origin(), 2234 root->appendNew<ArgumentRegValue>(proc, Origin(), GPRInfo::argumentGPR0), 2235 root->appendNew<ArgumentRegValue>(proc, Origin(), GPRInfo::argumentGPR1)), 2236 root->appendNew<ArgumentRegValue>(proc, Origin(), GPRInfo::argumentGPR2))); 2237 2238 CHECK(compileAndRun<int>(proc, a, b, c) == (a+b)-c); 2239 } 2240 2241 void testSubFirstNeg(int a, int b) 2242 { 2243 Procedure proc; 2244 BasicBlock* root = proc.addBlock(); 2245 root->appendNewControlValue( 2246 proc, Return, Origin(), 2247 root->appendNew<Value>( 2248 proc, Sub, Origin(), 2249 root->appendNew<Value>(proc, Neg, Origin(), 2250 root->appendNew<ArgumentRegValue>(proc, Origin(), GPRInfo::argumentGPR0)), 2251 root->appendNew<ArgumentRegValue>(proc, Origin(), GPRInfo::argumentGPR1))); 2252 2253 CHECK(compileAndRun<int>(proc, a, b) == (-a)-b); 2191 2254 } 2192 2255 … … 17457 17520 RUN_BINARY(testNegMulArgImm, int64Operands(), int64Operands()); 17458 17521 RUN_TERNARY(testSubMulMulArgs, int64Operands(), int64Operands(), int64Operands()); 17522 17523 RUN_TERNARY(testSubSub, int32Operands(), int32Operands(), int32Operands()); 17524 RUN_TERNARY(testSubSub2, int32Operands(), int32Operands(), int32Operands()); 17525 RUN_TERNARY(testSubAdd, int32Operands(), int32Operands(), int32Operands()); 17526 RUN_BINARY(testSubFirstNeg, int32Operands(), int32Operands()); 17459 17527 17460 17528 RUN(testSubArgs32(1, 1));
Note: See TracChangeset
for help on using the changeset viewer.