diff --git a/flang/lib/Optimizer/Builder/Character.cpp b/flang/lib/Optimizer/Builder/Character.cpp --- a/flang/lib/Optimizer/Builder/Character.cpp +++ b/flang/lib/Optimizer/Builder/Character.cpp @@ -419,7 +419,8 @@ auto rhsCstLen = getCompileTimeLength(rhs); auto lhsCstLen = getCompileTimeLength(lhs); bool compileTimeSameLength = - lhsCstLen && rhsCstLen && *lhsCstLen == *rhsCstLen; + (lhsCstLen && rhsCstLen && *lhsCstLen == *rhsCstLen) || + (rhs.getLen() == lhs.getLen()); if (compileTimeSameLength && *lhsCstLen == 1) { createLengthOneAssign(lhs, rhs); diff --git a/flang/test/Lower/OpenMP/omp-parallel-lastprivate-clause-scalar.f90 b/flang/test/Lower/OpenMP/omp-parallel-lastprivate-clause-scalar.f90 --- a/flang/test/Lower/OpenMP/omp-parallel-lastprivate-clause-scalar.f90 +++ b/flang/test/Lower/OpenMP/omp-parallel-lastprivate-clause-scalar.f90 @@ -30,15 +30,6 @@ !CHECK-DAG: %[[CVT:.*]] = fir.convert %[[ARG1_UNBOX]]#0 : (!fir.ref>) -> !fir.ref !CHECK-DAG: %[[CVT1:.*]] = fir.convert %[[ARG1_PVT]] : (!fir.ref>) -> !fir.ref !CHECK-DAG: fir.call @llvm.memmove.p0.p0.i64(%[[CVT]], %[[CVT1]]{{.*}}) -!CHECK: %[[THIRTY_TWO:.*]] = arith.constant 32 : i8 -!CHECK-DAG: %[[UNDEF:.*]] = fir.undefined !fir.char<1> -!CHECK-DAG: %[[INSERT:.*]] = fir.insert_value %[[UNDEF]], %[[THIRTY_TWO]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1> -!CHECK-DAG: %[[ONE_3:.*]] = arith.constant 1 : index -!CHECK: fir.do_loop %[[ARG2:.*]] = {{.*}} { -!CHECK-DAG: %[[CVT_2:.*]] = fir.convert %[[ARG1_UNBOX]]#0 : (!fir.ref>) -> !fir.ref>> -!CHECK-DAG: %[[COORD:.*]] = fir.coordinate_of %[[CVT_2]], %[[ARG2]] : (!fir.ref>>, index) -> !fir.ref> -!CHECK-DAG: fir.store %[[INSERT]] to %[[COORD]] : !fir.ref> -!CHECK-DAG: } !CHECK-DAG: } !CHECK-DAG: omp.yield diff --git a/flang/test/Lower/array-expression.f90 b/flang/test/Lower/array-expression.f90 --- a/flang/test/Lower/array-expression.f90 +++ b/flang/test/Lower/array-expression.f90 @@ -998,20 +998,6 @@ ! CHECK: %[[VAL_30:.*]] = fir.do_loop %[[VAL_31:.*]] = %[[VAL_28]] to %[[VAL_29]] step %[[VAL_27]] unordered iter_args(%[[VAL_32:.*]] = %[[VAL_15]]) -> (!fir.array<70x!fir.char<4,?>>) { ! CHECK: %[[VAL_33:.*]] = fir.array_access %[[VAL_24]], %[[VAL_31]] : (!fir.array<140x!fir.char<2,13>>, index) -> !fir.ref> ! CHECK: %[[VAL_34:.*]] = fir.alloca !fir.char<4,?>(%[[VAL_4]] : index) -! CHECK: %[[VAL_35:.*]] = arith.cmpi slt, %[[VAL_4]], %[[VAL_4]] : index -! CHECK: %[[VAL_36:.*]] = arith.select %[[VAL_35]], %[[VAL_4]], %[[VAL_4]] : index -! CHECK: fir.char_convert %[[VAL_33]] for %[[VAL_36]] to %[[VAL_34]] : !fir.ref>, index, !fir.ref> -! CHECK: %[[VAL_37:.*]] = arith.constant 1 : index -! CHECK: %[[VAL_38:.*]] = arith.subi %[[VAL_4]], %[[VAL_37]] : index -! CHECK: %[[VAL_39:.*]] = arith.constant 32 : i32 -! CHECK: %[[VAL_40:.*]] = fir.undefined !fir.char<4> -! CHECK: %[[VAL_41:.*]] = fir.insert_value %[[VAL_40]], %[[VAL_39]], [0 : index] : (!fir.char<4>, i32) -> !fir.char<4> -! CHECK: %[[VAL_42:.*]] = arith.constant 1 : index -! CHECK: fir.do_loop %[[VAL_43:.*]] = %[[VAL_36]] to %[[VAL_38]] step %[[VAL_42]] { -! CHECK: %[[VAL_44:.*]] = fir.convert %[[VAL_34]] : (!fir.ref>) -> !fir.ref>> -! CHECK: %[[VAL_45:.*]] = fir.coordinate_of %[[VAL_44]], %[[VAL_43]] : (!fir.ref>>, index) -> !fir.ref> -! CHECK: fir.store %[[VAL_41]] to %[[VAL_45]] : !fir.ref> -! CHECK: } ! CHECK: %[[VAL_46:.*]] = fir.array_access %[[VAL_32]], %[[VAL_31]] typeparams %[[VAL_11]] : (!fir.array<70x!fir.char<4,?>>, index, i32) -> !fir.ref> ! CHECK: %[[VAL_47:.*]] = fir.convert %[[VAL_11]] : (i32) -> index ! CHECK: %[[VAL_48:.*]] = fir.convert %[[VAL_26]] : (i64) -> index