<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hi Archie!<br>
<br>
The C2 compiler can use <i>automatic vectorization</i> [1] to speed up such operations. You can watch my explanation of the concept in some of my recent presentations, e.g, [2]<br>
<br>
Best, Per</div>
<div class="_Entity _EType_OWALinkPreview _EId_OWALinkPreview_1 _EReadonly_1" style="width: 100%; display: inline-block;">
<div id="LPBorder_GTaHR0cHM6Ly95b3V0dS5iZS9yWHYyLWxONVhnaz90PTE1MTg." class="LPBorder585086" style="width: 100%; margin-top: 16px; margin-bottom: 16px; position: relative; max-width: 800px; min-width: 424px;">
<table id="LPContainer585086" role="presentation" style="padding: 12px 36px 12px 12px; width: 100%; border-width: 1px; border-style: solid; border-color: rgb(200, 200, 200); border-radius: 2px;">
<tbody>
<tr valign="top" style="border-spacing: 0px;">
<td style="width: 100%;">
<div id="LPTitle585086" style="font-size: 21px; font-weight: 300; margin-right: 8px; font-family: wf_segoe-ui_light, "Segoe UI Light", "Segoe WP Light", "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; margin-bottom: 12px;">
<a target="_blank" id="LPUrlAnchor585086" href="https://youtu.be/rXv2-lN5Xgk?t=1518" style="text-decoration: none; color: var(--themePrimary);">YouTube</a></div>
<div id="LPDescription585086" style="font-size: 14px; max-height: 100px; color: rgb(102, 102, 102); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; margin-bottom: 12px; margin-right: 8px; overflow: hidden;">
Share your videos with friends, family, and the world</div>
<div id="LPMetadata585086" style="font-size: 14px; font-weight: 400; color: rgb(166, 166, 166); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif;">
youtu.be</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="_Entity _EType_OWALinkPreview _EId_OWALinkPreview _EReadonly_1" style="width: 100%; display: inline-block;">
<div id="LPBorder_GTaHR0cHM6Ly9lbi53aWtpcGVkaWEub3JnL3dpa2kvQXV0b21hdGljX3ZlY3Rvcml6YXRpb24." class="LPBorder382363" style="width: 100%; margin-top: 16px; margin-bottom: 16px; position: relative; max-width: 800px; min-width: 424px;">
<table id="LPContainer382363" role="presentation" style="padding: 12px 36px 12px 12px; width: 100%; border-width: 1px; border-style: solid; border-color: rgb(200, 200, 200); border-radius: 2px;">
<tbody>
<tr valign="top" style="border-spacing: 0px;">
<td style="width: 100%;">
<div id="LPTitle382363" style="font-size: 21px; font-weight: 300; margin-right: 8px; font-family: wf_segoe-ui_light, "Segoe UI Light", "Segoe WP Light", "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; margin-bottom: 12px;">
<a target="_blank" id="LPUrlAnchor382363" href="https://en.wikipedia.org/wiki/Automatic_vectorization" style="text-decoration: none; color: var(--themePrimary);">Automatic vectorization - Wikipedia</a></div>
<div id="LPDescription382363" style="font-size: 14px; max-height: 100px; color: rgb(102, 102, 102); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; margin-bottom: 12px; margin-right: 8px; overflow: hidden;">
Automatic vectorization, in parallel computing, is a special case of automatic parallelization, where a computer program is converted from a scalar implementation, which processes a single pair of operands at a time, to a vector implementation, which processes
 one operation on multiple pairs of operands at once. For example, modern conventional computers, including specialized supercomputers ...</div>
<div id="LPMetadata382363" style="font-size: 14px; font-weight: 400; color: rgb(166, 166, 166); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif;">
en.wikipedia.org</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
[1] <a href="https://en.wikipedia.org/wiki/Automatic_vectorization" id="LPlnk162055">
https://en.wikipedia.org/wiki/Automatic_vectorization</a></div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
[2] <a href="https://youtu.be/rXv2-lN5Xgk?t=1518" id="LPlnk773235">https://youtu.be/rXv2-lN5Xgk?t=1518</a></div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> core-libs-dev <core-libs-dev-retn@openjdk.org> on behalf of Archie Cobbs <archie.cobbs@gmail.com><br>
<b>Sent:</b> Thursday, May 22, 2025 10:58 PM<br>
<b>To:</b> John R Rose <jrose@openjdk.org><br>
<b>Cc:</b> core-libs-dev@openjdk.org <core-libs-dev@openjdk.org><br>
<b>Subject:</b> Re: RFR: 8357531: The `SegmentBulkOperations::fill` method can be improved using overlaps [v5]</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div dir="ltr">On Thu, May 22, 2025 at 3:31 PM John R Rose <<a href="mailto:jrose@openjdk.org">jrose@openjdk.org</a>> wrote:</div>
<div class="x_gmail_quote x_gmail_quote_container">
<blockquote class="x_gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
>   Update benchmark to reflect new fill method<br>
<br>
Related discussion at the hardware level:<br>
<br>
<a href="https://github.com/openjdk/jdk/pull/25147#issuecomment-2902463076" rel="noreferrer" target="_blank">https://github.com/openjdk/jdk/pull/25147#issuecomment-2902463076</a>
<br>
</blockquote>
</div>
<div><br clear="all">
</div>
<div>This discussion spurred me to ask a dumb question. Apologies in advance, just trying to learn here...
<div><br>
</div>
<div>If I do this:</div>
<div><br>
</div>
<div style="margin-left:40px"><span style="font-family:monospace">import java.util.Arrays;<br>
public class ArrayFiller {<br>
    public static void main(String[] args) {<br>
        while (true) {<br>
            final byte[] array = new byte[1000000];<br>
            Arrays.fill(array, (byte)0x42);<br>
        }<br>
    }<br>
}<br>
</span></div>
<div><br>
</div>
<div>Will C2 compile <span style="font-family:monospace"><a href="https://github.com/openjdk/jdk/blob/139a05d05959a84541a29dfae6151f92ce579ae6/src/java.base/share/classes/java/util/Arrays.java#L3275-L3308">Arrays.fill()</a></span> into something that is more
 efficient than a byte-at-a-time loop like what appears in the source code?</div>
<div><br>
</div>
<div>Thanks,</div>
<div>-Archie</div>
</div>
<div><br>
</div>
<span class="x_gmail_signature_prefix">-- </span><br>
<div dir="ltr" class="x_gmail_signature">Archie L. Cobbs<br>
</div>
</div>
</div>
</body>
</html>