In Xcomp mode, an abnormal result is output

XMLWordPrintable

      ADDITIONAL SYSTEM INFORMATION :
      - JAVA version: "25.0.3-internal" 2026-04-21 (I didn't find it in the drop-down box)
      - Operating system: Linux
      - Compiler/toolchain: GCC 9.4
      - Source commit: 748bc9b1d3029fdaa66a2ba7bf8d02edc35edf3e
      - Build type: fastdebug


      A DESCRIPTION OF THE PROBLEM :
      Running the following program in -Xcomp will output incorrect results:
      ```
      String lv_String_1769426579536_77075171720402640:: `lmuffpccwhvawwgxihasdfasf123123`
      String lv_String_1769426579536_77075171720402640:: `lmuffpccwhvawwgxihasdfasf123123`
      unstable if: 5
      ```
      `
      Run the following program in -Xint and the result is normal:
      ```
      unstable if: 4
      ```

      Furthermore, if the content of the dontinline() function is empty (i.e., the code from line 7 to line 38 of the comment), the running result under -Xcomp will return to normal:
      ```
      unstable if: 4
      ```

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      java -Xcomp -Djdk.test.lib.random.seed=1 compiler.c2.TestMergeStoresAndAllocationElimination

      ---------- BEGIN SOURCE ----------
      package compiler.c2;

      public class TestMergeStoresAndAllocationElimination {
          static void dontinline() {
              String lv_String_1769426579536_77075171720402640 = new String("asdfasf123123");
              String lv_String_1769426579541_77075171762572811 = new String("");
              String lv_String_1769426579542_77075171780365412 = new String("");
              String lv_String_1769426579543_77075171783232983 = new String("");
              float lv_float_1769426579530_77075171661100560 = 912.6823f;
              float lv_float_1769426579541_77075171766088571 = 912.6823f;
              int lv_int_1769426579536_77075171716853370 = 522;
              int lv_int_1769426579541_77075171764661111 = 522;
              long lv_long_1769426579541_77075171765867741 = 83629L;
              long lv_long_1769426579541_77075171765679830 = 83629L;
              Object TmpVar_7707517178747179_1769426579543 = new Object();
              synchronized(TmpVar_7707517178747179_1769426579543) {
                  lv_float_1769426579530_77075171661100560 = 246.278f;
                  lv_String_1769426579536_77075171720402640 += (AllFuzzerDefs_1769426578553_43988.gb_String_1769426579536_77075171719166580);
                  
                  lv_String_1769426579541_77075171762572811 = lv_String_1769426579536_77075171720402640.replaceAll((lv_String_1769426579541_77075171762572811), (AllFuzzerDefs_1769426578553_43988.gb_String_1769426579540_77075171760669751));
                  
                  for (lv_int_1769426579541_77075171764661111 = 0; lv_int_1769426579541_77075171764661111 < (((lv_int_1769426579541_77075171764661111) + (lv_int_1769426579536_77075171716853370)) + AllFuzzerDefs_1769426578553_43988.gb_int_1769426579541_77075171765128071); lv_int_1769426579541_77075171764661111++) {
                      lv_int_1769426579536_77075171716853370 = lv_int_1769426579536_77075171716853370 + lv_int_1769426579541_77075171764661111;
                      if (false) { System.out.println("Ciallo~(∠·ω< )⌒★"); }
                      lv_long_1769426579541_77075171765679830 = lv_long_1769426579541_77075171765867741;
                      lv_String_1769426579536_77075171720402640 = "lmuffpccwhvawwgxih";
                      lv_String_1769426579536_77075171720402640 += (AllFuzzerDefs_1769426578553_43988.gb_String_1769426579541_77075171766882722);
                      
                      lv_float_1769426579541_77075171766088571 = 756.8578f;
                  
                  }
                  
                      
              }
              
              System.out.println(("String lv_String_1769426579536_77075171720402640:: `" + lv_String_1769426579536_77075171720402640) + "`");
             
          }
          static int test(boolean flag) {
              int[] arr = new int[4];
         
              arr[0] = 0x10000;
              arr[1] = 0x100000;
              arr[2] = 0x100;
              arr[3] = 0x1000000;
          
              compiler.c2.TestMergeStoresAndAllocationElimination.dontinline();
          
              arr[0] = 0x1;
              arr[1] = 0x10;
             
              if (flag) {
                  java.lang.System.out.println("unstable if: " + arr.length);
              }

              for (int i = 0; i < 10000; i++) {
                  arr[3] = 0x1000;
              }

              return (((1 * arr[0]) + (2 * arr[1])) + (3 * arr[2])) + (4 * arr[3]);
          }
         
          public static void main(java.lang.String[] args) {
              // Capture interpreter result.
              int gold = compiler.c2.TestMergeStoresAndAllocationElimination.test(false);
              // Repeat until we get compilation.
              for (int i = 0; i < 10000; i++) {
                  compiler.c2.TestMergeStoresAndAllocationElimination.test(false);
              }
              // Capture compiled results.
              int res0 = compiler.c2.TestMergeStoresAndAllocationElimination.test(false);
              int res1 = compiler.c2.TestMergeStoresAndAllocationElimination.test(true);
              if ((res0 != gold) || (res1 != gold)) {
                  throw new java.lang.RuntimeException((((("Unexpected result: " + java.lang.Integer.toHexString(res0)) + " and ") + java.lang.Integer.toHexString(res1)) + ", should be: ") + java.lang.Integer.toHexString(gold));
              }
          }
      }

      class AllFuzzerDefs_1769426578553_43988 {

          public static int ARRAY_SIZE = 80;

          public static String gb_String_1769426579536_77075171719166580 = new String("asdfasf123123");

          public static String gb_String_1769426579541_77075171766882722 = new String("asdfasf123123");

          public static String gb_String_1769426579540_77075171760669751 = new String("asdfasf123123");

          public static int gb_int_1769426579541_77075171765128071 = 522;

          public static int gb_int_1769426579536_77075171717098860 = 522;

      }

      ---------- END SOURCE ----------

      FREQUENCY :
      ALWAYS

            Assignee:
            Unassigned
            Reporter:
            Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: