[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.
This commit is contained in:
Razvan Lupusoru 2024-05-10 07:45:35 -07:00 committed by GitHub
parent 9232591b04
commit c5c8ae4354
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 5 additions and 10 deletions

View File

@ -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 =

View File

@ -19,8 +19,7 @@ call system(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>

View File

@ -15,8 +15,7 @@ call system(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 @@ call system(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>