AI should do int32 optimization in ValueRep
https://bugs.webkit.org/show_bug.cgi?id=238699

Reviewed by Saam Barati.

When constant folding an int52 into a ValueRep AI doesn't
do our normal int32 boxing optimization. I'm not sure if
it matters since I couldn't find a test but it probably
doesn't hurt.

* dfg/DFGAbstractInterpreterInlines.h:
(JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@292269 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog
index 27871a0..b1e91da 100644
--- a/Source/JavaScriptCore/ChangeLog
+++ b/Source/JavaScriptCore/ChangeLog
@@ -1,3 +1,18 @@
+2022-04-02  Keith Miller  <keith_miller@apple.com>
+
+        AI should do int32 optimization in ValueRep
+        https://bugs.webkit.org/show_bug.cgi?id=238699
+
+        Reviewed by Saam Barati.
+
+        When constant folding an int52 into a ValueRep AI doesn't
+        do our normal int32 boxing optimization. I'm not sure if
+        it matters since I couldn't find a test but it probably
+        doesn't hurt.
+
+        * dfg/DFGAbstractInterpreterInlines.h:
+        (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):
+
 2022-04-02  Adrian Perez de Castro  <aperez@igalia.com>
 
         [GTK] Replace gtk-doc with gi-docgen
diff --git a/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h b/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h
index 580f9e6..0f60b93 100644
--- a/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h
+++ b/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h
@@ -750,6 +750,10 @@
     case ValueRep: {
         JSValue value = forNode(node->child1()).value();
         if (value) {
+            if (node->child1().useKind() == Int52RepUse) {
+                if (auto int32 = value.tryGetAsInt32())
+                    value = jsNumber(*int32);
+            }
             setConstant(node, value);
             break;
         }