In some case the lowering of `ichar` is generating an `arith.extui` operation
with the same from/to type. This operation do not accept from/to types to be
the same. If the from/to types are identical, we do not generate the extra
operation.
Reviewed By: jeanPerier
Differential Revision: https://reviews.llvm.org/D124107
}
LLVM_DEBUG(llvm::dbgs() << "ichar(" << charVal << ")\n");
auto code = helper.extractCodeFromSingleton(charVal);
+ if (code.getType() == resultType)
+ return code;
return builder.create<mlir::arith::ExtUIOp>(loc, resultType, code);
}
! CHECK-NEXT: fir.call @{{.*}}EndIoStatement
print *, iachar('X')
end subroutine
+
+! Check that 'arith.extui' op is not generated if type are matching.
+ ! CHECK-LABEL: no_extui
+subroutine no_extui(ch)
+ integer, parameter :: kind = selected_char_kind('ISO_10646')
+ character(*, kind), intent(in) :: ch(:)
+ integer :: i, j
+ ! CHECK-NOT: arith.extui
+ j = ichar(ch(i)(i:i))
+end subroutine