[flang-commits] [PATCH] D139330: [flang] do not generate padding/truncation code when character length are equals
Jean Perier via Phabricator via flang-commits
flang-commits at lists.llvm.org
Tue Dec 6 00:34:48 PST 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9b9a8475d3ac: [flang] do not generate padding/truncation code when character length are equals (authored by jeanPerier).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D139330/new/
https://reviews.llvm.org/D139330
Files:
flang/lib/Optimizer/Builder/Character.cpp
flang/test/Lower/OpenMP/omp-parallel-lastprivate-clause-scalar.f90
flang/test/Lower/array-expression.f90
Index: flang/test/Lower/array-expression.f90
===================================================================
--- flang/test/Lower/array-expression.f90
+++ 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<!fir.char<2,13>>
! 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<!fir.char<2,13>>, index, !fir.ref<!fir.char<4,?>>
-! 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.char<4,?>>) -> !fir.ref<!fir.array<?x!fir.char<4>>>
-! CHECK: %[[VAL_45:.*]] = fir.coordinate_of %[[VAL_44]], %[[VAL_43]] : (!fir.ref<!fir.array<?x!fir.char<4>>>, index) -> !fir.ref<!fir.char<4>>
-! CHECK: fir.store %[[VAL_41]] to %[[VAL_45]] : !fir.ref<!fir.char<4>>
-! CHECK: }
! CHECK: %[[VAL_46:.*]] = fir.array_access %[[VAL_32]], %[[VAL_31]] typeparams %[[VAL_11]] : (!fir.array<70x!fir.char<4,?>>, index, i32) -> !fir.ref<!fir.char<4,?>>
! CHECK: %[[VAL_47:.*]] = fir.convert %[[VAL_11]] : (i32) -> index
! CHECK: %[[VAL_48:.*]] = fir.convert %[[VAL_26]] : (i64) -> index
Index: flang/test/Lower/OpenMP/omp-parallel-lastprivate-clause-scalar.f90
===================================================================
--- flang/test/Lower/OpenMP/omp-parallel-lastprivate-clause-scalar.f90
+++ 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.char<1,?>>) -> !fir.ref<i8>
!CHECK-DAG: %[[CVT1:.*]] = fir.convert %[[ARG1_PVT]] : (!fir.ref<!fir.char<1,5>>) -> !fir.ref<i8>
!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.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
-!CHECK-DAG: %[[COORD:.*]] = fir.coordinate_of %[[CVT_2]], %[[ARG2]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
-!CHECK-DAG: fir.store %[[INSERT]] to %[[COORD]] : !fir.ref<!fir.char<1>>
-!CHECK-DAG: }
!CHECK-DAG: }
!CHECK-DAG: omp.yield
Index: flang/lib/Optimizer/Builder/Character.cpp
===================================================================
--- flang/lib/Optimizer/Builder/Character.cpp
+++ 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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139330.480362.patch
Type: text/x-patch
Size: 4164 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20221206/e5d7e510/attachment.bin>
More information about the flang-commits
mailing list