Title: [195621] trunk/Source/_javascript_Core
- Revision
- 195621
- Author
- fpi...@apple.com
- Date
- 2016-01-26 14:07:28 -0800 (Tue, 26 Jan 2016)
Log Message
Shifts by an amount computed using BitAnd with a mask that subsumes the shift's own mask should be rewired around the BitAnd
https://bugs.webkit.org/show_bug.cgi?id=153505
Reviewed by Saam Barati.
Turn this: Shl(@x, BitAnd(@y, 63))
Into this: Shl(@x, @y)
It matters for Octane/crypto.
We should also stop FTL from generating such code, but even if we did that, we'd still want
this optimization in case user code did the BitAnd.
Also we can't stop the FTL from generating such code yet, because when targetting LLVM, you
must mask your shifts this way.
* b3/B3ReduceStrength.cpp:
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (195620 => 195621)
--- trunk/Source/_javascript_Core/ChangeLog 2016-01-26 22:05:28 UTC (rev 195620)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-01-26 22:07:28 UTC (rev 195621)
@@ -1,5 +1,25 @@
2016-01-26 Filip Pizlo <fpi...@apple.com>
+ Shifts by an amount computed using BitAnd with a mask that subsumes the shift's own mask should be rewired around the BitAnd
+ https://bugs.webkit.org/show_bug.cgi?id=153505
+
+ Reviewed by Saam Barati.
+
+ Turn this: Shl(@x, BitAnd(@y, 63))
+ Into this: Shl(@x, @y)
+
+ It matters for Octane/crypto.
+
+ We should also stop FTL from generating such code, but even if we did that, we'd still want
+ this optimization in case user code did the BitAnd.
+
+ Also we can't stop the FTL from generating such code yet, because when targetting LLVM, you
+ must mask your shifts this way.
+
+ * b3/B3ReduceStrength.cpp:
+
+2016-01-26 Filip Pizlo <fpi...@apple.com>
+
The thing that B3 uses to describe a stack slot should not be a Value
https://bugs.webkit.org/show_bug.cgi?id=153491
rdar://problem/24349446
Modified: trunk/Source/_javascript_Core/b3/B3ReduceStrength.cpp (195620 => 195621)
--- trunk/Source/_javascript_Core/b3/B3ReduceStrength.cpp 2016-01-26 22:05:28 UTC (rev 195620)
+++ trunk/Source/_javascript_Core/b3/B3ReduceStrength.cpp 2016-01-26 22:07:28 UTC (rev 195621)
@@ -816,7 +816,7 @@
break;
}
- if (handleShiftByZero())
+ if (handleShiftAmount())
break;
break;
@@ -878,7 +878,7 @@
break;
}
- if (handleShiftByZero())
+ if (handleShiftAmount())
break;
break;
@@ -891,7 +891,7 @@
break;
}
- if (handleShiftByZero())
+ if (handleShiftAmount())
break;
break;
@@ -1886,14 +1886,29 @@
return true;
}
- bool handleShiftByZero()
+ bool handleShiftAmount()
{
// Shift anything by zero is identity.
- if (m_value->child(1)->isInt(0)) {
+ if (m_value->child(1)->isInt32(0)) {
m_value->replaceWithIdentity(m_value->child(0));
m_changed = true;
return true;
}
+
+ // The shift already masks its shift amount. If the shift amount is being masked by a
+ // redundant amount, then remove the mask. For example,
+ // Turn this: Shl(@x, BitAnd(@y, 63))
+ // Into this: Shl(@x, @y)
+ unsigned mask = sizeofType(m_value->type()) * 8 - 1;
+ if (m_value->child(1)->opcode() == BitAnd
+ && m_value->child(1)->child(1)->hasInt32()
+ && (m_value->child(1)->child(1)->asInt32() & mask) == mask) {
+ m_value->child(1) = m_value->child(1)->child(0);
+ m_changed = true;
+ // Don't need to return true, since we're still the same shift, and we can still cascade
+ // through other optimizations.
+ }
+
return false;
}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes