[flang-commits] [flang] [flang] Preserve DO variable updates through aliases (PR #211191)

via flang-commits flang-commits at lists.llvm.org
Wed Jul 22 01:12:53 PDT 2026


github-actions[bot] wrote:

<!--PREMERGE ADVISOR COMMENT: Linux-->
# :penguin: Linux x64 Test Results

* 4663 tests passed
* 135 tests skipped
* 2 tests failed

## Failed Tests
(click on a test name to see its output)

### Flang
<details>
<summary>Flang.Lower/do_loop_alias_update.f90</summary>

```
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/flang -fc1 -fintrinsic-modules-path=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/24/finclude/flang/x86_64-unknown-linux-gnu -emit-hlfir -mmlir --unsafe-cray-pointers -o - /home/gha/actions-runner/_work/llvm-project/llvm-project/flang/test/Lower/do_loop_alias_update.f90 | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/flang/test/Lower/do_loop_alias_update.f90
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/flang -fc1 -fintrinsic-modules-path=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/24/finclude/flang/x86_64-unknown-linux-gnu -emit-hlfir -mmlir --unsafe-cray-pointers -o - /home/gha/actions-runner/_work/llvm-project/llvm-project/flang/test/Lower/do_loop_alias_update.f90
# note: command had no output on stdout or stderr
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/flang/test/Lower/do_loop_alias_update.f90
# .---command stderr------------
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/flang/test/Lower/do_loop_alias_update.f90:24:11: error: CHECK: expected string not found in input
# |  ! CHECK: %[[NEXT:.*]] = arith.addi %[[UPDATED]], %[[STEP]] overflow<nsw> : i32
# |           ^
# | <stdin>:30:37: note: scanning from here
# |  %16 = fir.load %3#0 : !fir.ref<i32>
# |                                     ^
# | <stdin>:30:37: note: with "UPDATED" equal to "16"
# |  %16 = fir.load %3#0 : !fir.ref<i32>
# |                                     ^
# | <stdin>:30:37: note: with "STEP" equal to "c-2_i32_0"
# |  %16 = fir.load %3#0 : !fir.ref<i32>
# |                                     ^
# | <stdin>:30:37: note: pattern attempts to capture variables: "NEXT"
# |  %16 = fir.load %3#0 : !fir.ref<i32>
# |                                     ^
# | <stdin>:43:11: note: possible intended match here
# |  %26 = arith.addi %25, %c-2_i32_0 overflow<nsw> : i32
# |           ^
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/flang/test/Lower/do_loop_alias_update.f90:48:11: error: CHECK: expected string not found in input
# |  ! CHECK: %[[NEXT:.*]] = arith.addi %[[UPDATED]], %[[STEP]] overflow<nsw> : i32
# |           ^
# | <stdin>:64:36: note: scanning from here
# |  %8 = fir.load %2#0 : !fir.ref<i32>
# |                                    ^
# | <stdin>:64:36: note: with "UPDATED" equal to "8"
# |  %8 = fir.load %2#0 : !fir.ref<i32>
# |                                    ^
# | <stdin>:64:36: note: with "STEP" equal to "c1_i32_0"
# |  %8 = fir.load %2#0 : !fir.ref<i32>
# |                                    ^
# | <stdin>:64:36: note: pattern attempts to capture variables: "NEXT"
# |  %8 = fir.load %2#0 : !fir.ref<i32>
# |                                    ^
# | <stdin>:66:2: note: possible intended match here
# |  %9 = arith.addi %8, %c1_i32_1 : i32
# |  ^
# | 
# | Input file: <stdin>
# | Check file: /home/gha/actions-runner/_work/llvm-project/llvm-project/flang/test/Lower/do_loop_alias_update.f90
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |             .
# |             .
# |             .
# |            25:  fir.do_loop %arg0 = %c-2_i32 to %c-7_i32 step %c-2_i32_0 : i32 { 
# |            26:  %14 = fir.load %5#0 : !fir.ref<i32> 
# |            27:  %c5_i32 = arith.constant 5 : i32 
# |            28:  %15 = arith.addi %14, %c5_i32 : i32 
# |            29:  hlfir.assign %15 to %5#0 : i32, !fir.ref<i32> 
# |            30:  %16 = fir.load %3#0 : !fir.ref<i32> 
# | check:24'0                                        {   search range start (exclusive)
# | check:24'1                                            error: no match found in search range
# | check:24'2                                            with "UPDATED" equal to "16"
# | check:24'3                                            with "STEP" equal to "c-2_i32_0"
# | check:24'4                                            pattern attempts to capture variables: "NEXT"
# |            31:  %c3_i32 = arith.constant 3 : i32 
# |            32:  %17 = arith.subi %16, %c3_i32 : i32 
# |            33:  %18 = fir.convert %17 : (i32) -> f32 
# |            34:  %19 = fir.convert %7#0 : (!fir.ref<i64>) -> !fir.ref<!fir.ptr<i64>> 
# |            35:  %20 = fir.load %19 : !fir.ref<!fir.ptr<i64>> 
# |            36:  %21 = fir.convert %8#0 : (!fir.ref<!fir.box<!fir.ptr<f32>>>) -> !fir.ref<!fir.box<none>> 
# |            37:  %22 = fir.convert %20 : (!fir.ptr<i64>) -> !fir.llvm_ptr<i8> 
# |            38:  fir.call @_FortranAPointerAssociateScalar(%21, %22) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () 
# |            39:  %23 = fir.load %8#0 : !fir.ref<!fir.box<!fir.ptr<f32>>> 
# |            40:  %24 = fir.box_addr %23 : (!fir.box<!fir.ptr<f32>>) -> !fir.ptr<f32> 
# |            41:  hlfir.assign %18 to %24 : f32, !fir.ptr<f32> 
# |            42:  %25 = fir.load %3#0 : !fir.ref<i32> 
# |            43:  %26 = arith.addi %25, %c-2_i32_0 overflow<nsw> : i32 
# | check:24'5               ?                                             possible intended match
# |            44:  fir.store %26 to %3#0 : !fir.ref<i32> 
# |            45:  } 
# |            46:  return 
# |            47:  } 
# |            48:  func.func @_QPpointer_alias_loop() { 
# | check:24'6                                        }    search range end (exclusive)
# |            49:  %0 = fir.dummy_scope : !fir.dscope 
# |            50:  %1 = fir.alloca i32 {bindc_name = "i", fir.target, uniq_name = "_QFpointer_alias_loopEi"} 
# |            51:  %2:2 = hlfir.declare %1 {fortran_attrs = #fir.var_attrs<target>, uniq_name = "_QFpointer_alias_loopEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) 
# |            52:  %3 = fir.alloca !fir.box<!fir.ptr<i32>> {bindc_name = "p", uniq_name = "_QFpointer_alias_loopEp"} 
# |            53:  %4 = fir.zero_bits !fir.ptr<i32> 
# |             .
# |             .
# |             .
# |            59:  %c1_i32 = arith.constant 1 : i32 
# |            60:  %c3_i32 = arith.constant 3 : i32 
# |            61:  %c1_i32_0 = arith.constant 1 : i32 
# |            62:  fir.store %c1_i32 to %2#0 : !fir.ref<i32> 
# |            63:  fir.do_loop %arg0 = %c1_i32 to %c3_i32 step %c1_i32_0 : i32 { 
# |            64:  %8 = fir.load %2#0 : !fir.ref<i32> 
# | check:48'0                                       {   search range start (exclusive)
# | check:48'1                                           error: no match found in search range
# | check:48'2                                           with "UPDATED" equal to "8"
# | check:48'3                                           with "STEP" equal to "c1_i32_0"
# | check:48'4                                           pattern attempts to capture variables: "NEXT"
# |            65:  %c1_i32_1 = arith.constant 1 : i32 
# |            66:  %9 = arith.addi %8, %c1_i32_1 : i32 
# | check:48'5      ?                                     possible intended match
# |            67:  %10 = fir.load %6#0 : !fir.ref<!fir.box<!fir.ptr<i32>>> 
# |            68:  %11 = fir.box_addr %10 : (!fir.box<!fir.ptr<i32>>) -> !fir.ptr<i32> 
# |            69:  hlfir.assign %9 to %11 : i32, !fir.ptr<i32> 
# |            70:  %12 = fir.load %2#0 : !fir.ref<i32> 
# |            71:  %13 = arith.addi %12, %c1_i32_0 overflow<nsw> : i32 
# |            72:  fir.store %13 to %2#0 : !fir.ref<i32> 
# |            73:  } 
# |            74:  return 
# |            75:  } 
# |            76:  func.func private @_FortranAPointerAssociateScalar(!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) attributes {fir.runtime} 
# |            77: } 
# | check:48'6       } search range end (exclusive)
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

```
</details>
<details>
<summary>Flang.Transforms/DoConcurrent/skip_all_nested_loops.f90</summary>

```
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 4
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/flang -fc1 -fintrinsic-modules-path=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/24/finclude/flang/x86_64-unknown-linux-gnu -emit-hlfir -fopenmp -fdo-concurrent-to-openmp=host /home/gha/actions-runner/_work/llvm-project/llvm-project/flang/test/Transforms/DoConcurrent/skip_all_nested_loops.f90 -o -    | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/flang/test/Transforms/DoConcurrent/skip_all_nested_loops.f90 --check-prefixes=HOST,COMMON
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/flang -fc1 -fintrinsic-modules-path=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/24/finclude/flang/x86_64-unknown-linux-gnu -emit-hlfir -fopenmp -fdo-concurrent-to-openmp=host /home/gha/actions-runner/_work/llvm-project/llvm-project/flang/test/Transforms/DoConcurrent/skip_all_nested_loops.f90 -o -
# note: command had no output on stdout or stderr
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/flang/test/Transforms/DoConcurrent/skip_all_nested_loops.f90 --check-prefixes=HOST,COMMON
# .---command stderr------------
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/flang/test/Transforms/DoConcurrent/skip_all_nested_loops.f90:52:9: error: HOST: expected string not found in input
# | ! HOST: fir.store %[[J_IV]] to %[[ORIG_J_DECL]]#0
# |         ^
# | <stdin>:38:66: note: scanning from here
# |  fir.do_loop %arg1 = %c1_i32_0 to %c20_i32 step %c1_i32_1 : i32 {
# |                                                                  ^
# | <stdin>:38:66: note: with "J_IV" equal to "arg1"
# |  fir.do_loop %arg1 = %c1_i32_0 to %c20_i32 step %c1_i32_1 : i32 {
# |                                                                  ^
# | <stdin>:38:66: note: with "ORIG_J_DECL" equal to "7"
# |  fir.do_loop %arg1 = %c1_i32_0 to %c20_i32 step %c1_i32_1 : i32 {
# |                                                                  ^
# | <stdin>:49:2: note: possible intended match here
# |  fir.store %27 to %26#0 : !fir.ref<i32>
# |  ^
# | 
# | Input file: <stdin>
# | Check file: /home/gha/actions-runner/_work/llvm-project/llvm-project/flang/test/Transforms/DoConcurrent/skip_all_nested_loops.f90
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |             .
# |             .
# |             .
# |            33:  fir.store %20 to %19#0 : !fir.ref<i32> 
# |            34:  %c1_i32_0 = arith.constant 1 : i32 
# |            35:  %c20_i32 = arith.constant 20 : i32 
# |            36:  %c1_i32_1 = arith.constant 1 : i32 
# |            37:  fir.store %c1_i32_0 to %7#0 : !fir.ref<i32> 
# |            38:  fir.do_loop %arg1 = %c1_i32_0 to %c20_i32 step %c1_i32_1 : i32 { 
# | check:52'0                                                                     {   search range start (exclusive)
# | check:52'1                                                                         error: no match found in search range
# | check:52'2                                                                         with "J_IV" equal to "arg1"
# | check:52'3                                                                         with "ORIG_J_DECL" equal to "7"
# |            39:  %c1_i32_2 = arith.constant 1 : i32 
# |            40:  %21 = fir.convert %c1_i32_2 : (i32) -> index 
# |            41:  %c30_i32 = arith.constant 30 : i32 
# |            42:  %22 = fir.convert %c30_i32 : (i32) -> index 
# |            43:  %c1_3 = arith.constant 1 : index 
# |            44:  fir.do_concurrent { 
# |            45:  %25 = fir.alloca i32 {bindc_name = "k"} 
# |            46:  %26:2 = hlfir.declare %25 {uniq_name = "_QFEk"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) 
# |            47:  fir.do_concurrent.loop (%arg2) = (%21) to (%22) step (%c1_3) { 
# |            48:  %27 = fir.convert %arg2 : (index) -> i32 
# |            49:  fir.store %27 to %26#0 : !fir.ref<i32> 
# | check:52'4      ?                                        possible intended match
# |            50:  %28 = fir.load %19#0 : !fir.ref<i32> 
# |            51:  %29 = fir.load %7#0 : !fir.ref<i32> 
# |            52:  %30 = arith.muli %28, %29 : i32 
# |            53:  %31 = fir.load %26#0 : !fir.ref<i32> 
# |            54:  %32 = arith.addi %30, %31 : i32 
# |             .
# |             .
# |             .
# |            97:  fir.call @_QQmain() fastmath<contract> : () -> () 
# |            98:  %c0_i32 = arith.constant 0 : i32 
# |            99:  fir.call @_FortranAProgramEndStatement() fastmath<contract> : () -> () 
# |           100:  return %c0_i32 : i32 
# |           101:  } 
# |           102: } 
# | check:52'5       } search range end (exclusive)
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

```
</details>

If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the `infrastructure` label.

https://github.com/llvm/llvm-project/pull/211191


More information about the flang-commits mailing list