[flang-commits] [flang] c5c8ae4 - [flang] Use i16 instead of i2 for cmdstat (#91647)
via flang-commits
flang-commits at lists.llvm.org
Fri May 10 07:45:39 PDT 2024
Author: Razvan Lupusoru
Date: 2024-05-10T07:45:35-07:00
New Revision: c5c8ae43545e917e624edd93695d1b265bae1e5c
URL: https://github.com/llvm/llvm-project/commit/c5c8ae43545e917e624edd93695d1b265bae1e5c
DIFF: https://github.com/llvm/llvm-project/commit/c5c8ae43545e917e624edd93695d1b265bae1e5c.diff
LOG: [flang] Use i16 instead of i2 for cmdstat (#91647)
The code for preparing cmdstat was generating an i2 constant with value
0, casting it, and then storing it into i16 storage. Just generate i16
constant directly.
Added:
Modified:
flang/lib/Optimizer/Builder/IntrinsicCall.cpp
flang/test/Lower/Intrinsics/system-optional.f90
flang/test/Lower/Intrinsics/system.f90
Removed:
################################################################################
diff --git a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
index 9d72e76e2369d..dcbbc39b84eaa 100644
--- a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
+++ b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
@@ -6306,11 +6306,9 @@ void IntrinsicLibrary::genSystem(llvm::ArrayRef<fir::ExtendedValue> args) {
// Create a dummmy cmdstat to prevent EXECUTE_COMMAND_LINE terminate itself
// when cmdstat is assigned with a non-zero value but not present
mlir::Value tempValue =
- builder.createIntegerConstant(loc, builder.getI2Type(), 0);
+ builder.createIntegerConstant(loc, builder.getI16Type(), 0);
mlir::Value temp = builder.createTemporary(loc, builder.getI16Type());
- mlir::Value castVal =
- builder.createConvert(loc, builder.getI16Type(), tempValue);
- builder.create<fir::StoreOp>(loc, castVal, temp);
+ builder.create<fir::StoreOp>(loc, tempValue, temp);
mlir::Value cmdstatBox = builder.createBox(loc, temp);
mlir::Value cmdmsgBox =
diff --git a/flang/test/Lower/Intrinsics/system-optional.f90 b/flang/test/Lower/Intrinsics/system-optional.f90
index 8a2db132d6729..8001e76fb93bd 100644
--- a/flang/test/Lower/Intrinsics/system-optional.f90
+++ b/flang/test/Lower/Intrinsics/system-optional.f90
@@ -19,8 +19,7 @@ subroutine all_args(command, exitstat)
! CHECK-NEXT: %[[absentIntBox:.*]] = fir.absent !fir.box<i32>
! CHECK-NEXT: %[[exitstatRealBox:.*]] = arith.select %[[exitstatIsPresent]], %[[exitstatBox]], %[[absentIntBox]] : !fir.box<i32>
! CHECK-NEXT: %[[true:.*]] = arith.constant true
-! CHECK-NEXT: %[[c0_i2:.*]] = arith.constant 0 : i2
-! CHECK-NEXT: %[[c0_i16:.*]] = fir.convert %[[c0_i2]] : (i2) -> i16
+! CHECK-NEXT: %[[c0_i16:.*]] = arith.constant 0 : i16
! CHECK-NEXT: fir.store %[[c0_i16]] to %[[cmdstatVal]] : !fir.ref<i16>
! CHECK-NEXT: %[[cmdstatBox:.*]] = fir.embox %[[cmdstatVal]] : (!fir.ref<i16>) -> !fir.box<i16>
! CHECK-NEXT: %[[absentBox:.*]] = fir.absent !fir.box<none>
diff --git a/flang/test/Lower/Intrinsics/system.f90 b/flang/test/Lower/Intrinsics/system.f90
index 4ce3c553891de..71655938113f7 100644
--- a/flang/test/Lower/Intrinsics/system.f90
+++ b/flang/test/Lower/Intrinsics/system.f90
@@ -15,8 +15,7 @@ subroutine all_args(command, exitstat)
! CHECK-NEXT: %[[commandBox:.*]] = fir.embox %[[commandDeclare]]#1 typeparams %[[commandUnbox]]#1 : (!fir.ref<!fir.char<1,?>>, index) -> !fir.box<!fir.char<1,?>>
! CHECK-NEXT: %[[exitstatBox:.*]] = fir.embox %[[exitstatDeclare]]#1 : (!fir.ref<i32>) -> !fir.box<i32>
! CHECK-NEXT: %[[true:.*]] = arith.constant true
-! CHECK-NEXT: %[[c0_i2:.*]] = arith.constant 0 : i2
-! CHECK-NEXT: %[[c0_i16:.*]] = fir.convert %[[c0_i2]] : (i2) -> i16
+! CHECK-NEXT: %[[c0_i16:.*]] = arith.constant 0 : i16
! CHECK-NEXT: fir.store %[[c0_i16]] to %[[cmdstatVal]] : !fir.ref<i16>
! CHECK-NEXT: %[[cmdstatBox:.*]] = fir.embox %[[cmdstatVal]] : (!fir.ref<i16>) -> !fir.box<i16>
! CHECK-NEXT: %[[absentBox:.*]] = fir.absent !fir.box<none>
@@ -41,8 +40,7 @@ subroutine only_command(command)
! CHECK-NEXT: %[[commandBox:.*]] = fir.embox %[[commandDeclare]]#1 typeparams %[[commandUnbox]]#1 : (!fir.ref<!fir.char<1,?>>, index) -> !fir.box<!fir.char<1,?>>
! CHECK-NEXT: %[[true:.*]] = arith.constant true
! CHECK-NEXT: %[[absentBox:.*]] = fir.absent !fir.box<none>
-! CHECK-NEXT: %[[c0_i2:.*]] = arith.constant 0 : i2
-! CHECK-NEXT: %[[c0_i16:.*]] = fir.convert %[[c0_i2]] : (i2) -> i16
+! CHECK-NEXT: %[[c0_i16:.*]] = arith.constant 0 : i16
! CHECK-NEXT: fir.store %[[c0_i16]] to %[[cmdstatVal]] : !fir.ref<i16>
! CHECK-NEXT: %[[cmdstatBox:.*]] = fir.embox %[[cmdstatVal]] : (!fir.ref<i16>) -> !fir.box<i16>
! CHECK-NEXT: %[[absentBox2:.*]] = fir.absent !fir.box<none>
More information about the flang-commits
mailing list