Files
TheRock/compiler/amd-llvm/flang/test/Transforms/simplify-fir-operations.fir
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

153 lines
8.3 KiB
Plaintext

// RUN: fir-opt --split-input-file --simplify-fir-operations %s | FileCheck --check-prefixes=ALL,NOOPT %s
// RUN: fir-opt --split-input-file --simplify-fir-operations=prefer-inline-implementation=true %s | FileCheck --check-prefixes=ALL,OPT %s
func.func @test_none_innermost(%arg0: !fir.box<none>) -> i1 {
%0 = fir.is_contiguous_box %arg0 innermost : (!fir.box<none>) -> i1
return %0 : i1
}
// ALL-LABEL: func.func @test_none_innermost(
// ALL-SAME: %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: !fir.box<none>) -> i1 {
// ALL: %[[VAL_1:.*]] = arith.constant 1 : i32
// ALL: %[[VAL_2:.*]] = fir.call @_FortranAIsContiguousUpTo(%[[VAL_0]], %[[VAL_1]]) : (!fir.box<none>, i32) -> i1
// ALL: return %[[VAL_2]] : i1
// -----
func.func @test_none_whole(%arg0: !fir.box<none>) -> i1 {
%0 = fir.is_contiguous_box %arg0 whole : (!fir.box<none>) -> i1
return %0 : i1
}
// ALL-LABEL: func.func @test_none_whole(
// ALL-SAME: %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: !fir.box<none>) -> i1 {
// ALL: %[[VAL_1:.*]] = fir.call @_FortranAIsContiguous(%[[VAL_0]]) : (!fir.box<none>) -> i1
// ALL: return %[[VAL_1]] : i1
// ALL: }
// -----
func.func @test_array_innermost(%arg0: !fir.box<!fir.array<?xf32>>) -> i1 {
%0 = fir.is_contiguous_box %arg0 innermost : (!fir.box<!fir.array<?xf32>>) -> i1
return %0 : i1
}
// ALL-LABEL: func.func @test_array_innermost(
// ALL-SAME: %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: !fir.box<!fir.array<?xf32>>) -> i1 {
// NOOPT: %[[VAL_1:.*]] = arith.constant 1 : i32
// NOOPT: %[[VAL_2:.*]] = fir.convert %[[VAL_0]] : (!fir.box<!fir.array<?xf32>>) -> !fir.box<none>
// NOOPT: %[[VAL_3:.*]] = fir.call @_FortranAIsContiguousUpTo(%[[VAL_2]], %[[VAL_1]]) : (!fir.box<none>, i32) -> i1
// NOOPT: return %[[VAL_3]] : i1
// OPT: %[[VAL_1:.*]] = arith.constant 0 : index
// OPT: %[[VAL_2:.*]] = fir.box_elesize %[[VAL_0]] : (!fir.box<!fir.array<?xf32>>) -> index
// OPT: %[[VAL_3:.*]]:3 = fir.box_dims %[[VAL_0]], %[[VAL_1]] : (!fir.box<!fir.array<?xf32>>, index) -> (index, index, index)
// OPT: %[[VAL_4:.*]] = arith.cmpi eq, %[[VAL_2]], %[[VAL_3]]#2 : index
// OPT: %[[VAL_5:.*]] = arith.cmpi eq, %[[VAL_3]]#1, %[[VAL_1]] : index
// OPT: %[[VAL_6:.*]] = arith.ori %[[VAL_4]], %[[VAL_5]] : i1
// OPT: return %[[VAL_6]] : i1
// -----
func.func @test_array_whole(%arg0: !fir.box<!fir.array<?xf32>>) -> i1 {
%0 = fir.is_contiguous_box %arg0 whole : (!fir.box<!fir.array<?xf32>>) -> i1
return %0 : i1
}
// ALL-LABEL: func.func @test_array_whole(
// ALL-SAME: %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: !fir.box<!fir.array<?xf32>>) -> i1 {
// NOOPT: %[[VAL_1:.*]] = fir.convert %[[VAL_0]] : (!fir.box<!fir.array<?xf32>>) -> !fir.box<none>
// NOOPT: %[[VAL_2:.*]] = fir.call @_FortranAIsContiguous(%[[VAL_1]]) : (!fir.box<none>) -> i1
// NOOPT: return %[[VAL_2]] : i1
// OPT: %[[VAL_1:.*]] = arith.constant 0 : index
// OPT: %[[VAL_2:.*]] = fir.box_elesize %[[VAL_0]] : (!fir.box<!fir.array<?xf32>>) -> index
// OPT: %[[VAL_3:.*]]:3 = fir.box_dims %[[VAL_0]], %[[VAL_1]] : (!fir.box<!fir.array<?xf32>>, index) -> (index, index, index)
// OPT: %[[VAL_4:.*]] = arith.cmpi eq, %[[VAL_2]], %[[VAL_3]]#2 : index
// OPT: %[[VAL_5:.*]] = arith.cmpi eq, %[[VAL_3]]#1, %[[VAL_1]] : index
// OPT: %[[VAL_6:.*]] = arith.ori %[[VAL_4]], %[[VAL_5]] : i1
// OPT: return %[[VAL_6]] : i1
// -----
func.func @test_assumed_rank_innermost(%arg0: !fir.box<!fir.array<*:f32>>) -> i1 {
%0 = fir.is_contiguous_box %arg0 innermost : (!fir.box<!fir.array<*:f32>>) -> i1
return %0 : i1
}
// ALL-LABEL: func.func @test_assumed_rank_innermost(
// ALL-SAME: %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: !fir.box<!fir.array<*:f32>>) -> i1 {
// ALL: %[[VAL_1:.*]] = arith.constant 1 : i32
// ALL: %[[VAL_2:.*]] = fir.convert %[[VAL_0]] : (!fir.box<!fir.array<*:f32>>) -> !fir.box<none>
// ALL: %[[VAL_3:.*]] = fir.call @_FortranAIsContiguousUpTo(%[[VAL_2]], %[[VAL_1]]) : (!fir.box<none>, i32) -> i1
// ALL: return %[[VAL_3]] : i1
// -----
func.func @test_assumed_rank_whole(%arg0: !fir.box<!fir.array<*:f32>>) -> i1 {
%0 = fir.is_contiguous_box %arg0 whole : (!fir.box<!fir.array<*:f32>>) -> i1
return %0 : i1
}
// ALL-LABEL: func.func @test_assumed_rank_whole(
// ALL-SAME: %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: !fir.box<!fir.array<*:f32>>) -> i1 {
// ALL: %[[VAL_1:.*]] = fir.convert %[[VAL_0]] : (!fir.box<!fir.array<*:f32>>) -> !fir.box<none>
// ALL: %[[VAL_2:.*]] = fir.call @_FortranAIsContiguous(%[[VAL_1]]) : (!fir.box<none>) -> i1
// ALL: return %[[VAL_2]] : i1
// ALL: }
// -----
func.func @test_scalar_upoly(%arg0: !fir.class<none>) -> i1 {
%0 = fir.is_contiguous_box %arg0 innermost : (!fir.class<none>) -> i1
return %0 : i1
}
// ALL-LABEL: func.func @test_scalar_upoly(
// ALL-SAME: %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: !fir.class<none>) -> i1 {
// ALL: %[[VAL_1:.*]] = arith.constant 1 : i32
// ALL: %[[VAL_2:.*]] = fir.convert %[[VAL_0]] : (!fir.class<none>) -> !fir.box<none>
// ALL: %[[VAL_3:.*]] = fir.call @_FortranAIsContiguousUpTo(%[[VAL_2]], %[[VAL_1]]) : (!fir.box<none>, i32) -> i1
// ALL: return %[[VAL_3]] : i1
// -----
func.func @test_none(%arg0: !fir.box<none>) -> i16 {
%0 = fir.box_total_elements %arg0 : (!fir.box<none>) -> i16
return %0 : i16
}
// ALL-LABEL: func.func @test_none(
// ALL-SAME: %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: !fir.box<none>) -> i16 {
// ALL: %[[VAL_3:.*]] = arith.constant {{.*}} : i32
// ALL: %[[VAL_1:.*]] = fir.address_of(@{{.*}}) : !fir.ref<!fir.char<1,{{.*}}>>
// ALL: %[[VAL_4:.*]] = fir.convert %[[VAL_1]] : (!fir.ref<!fir.char<1,{{.*}}>>) -> !fir.ref<i8>
// ALL: %[[VAL_5:.*]] = fir.call @_FortranASize(%[[VAL_0]], %[[VAL_4]], %[[VAL_3]]) : (!fir.box<none>, !fir.ref<i8>, i32) -> i64
// ALL: %[[VAL_6:.*]] = fir.convert %[[VAL_5]] : (i64) -> i16
// ALL: return %[[VAL_6]] : i16
// ALL: }
// -----
func.func @test_array(%arg0: !fir.box<!fir.array<?x?xf32>>) -> i32 {
%0 = fir.box_total_elements %arg0 : (!fir.box<!fir.array<?x?xf32>>) -> i32
return %0 : i32
}
// ALL-LABEL: func.func @test_array(
// ALL-SAME: %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: !fir.box<!fir.array<?x?xf32>>) -> i32 {
// ALL: %[[VAL_3:.*]] = arith.constant {{.*}} : i32
// ALL: %[[VAL_1:.*]] = fir.address_of({{.*}}) : !fir.ref<!fir.char<1,{{.*}}>>
// ALL: %[[VAL_4:.*]] = fir.convert %[[VAL_0]] : (!fir.box<!fir.array<?x?xf32>>) -> !fir.box<none>
// ALL: %[[VAL_5:.*]] = fir.convert %[[VAL_1]] : (!fir.ref<!fir.char<1,{{.*}}>>) -> !fir.ref<i8>
// ALL: %[[VAL_6:.*]] = fir.call @_FortranASize(%[[VAL_4]], %[[VAL_5]], %[[VAL_3]]) : (!fir.box<none>, !fir.ref<i8>, i32) -> i64
// ALL: %[[VAL_7:.*]] = fir.convert %[[VAL_6]] : (i64) -> i32
// ALL: return %[[VAL_7]] : i32
// ALL: }
// -----
func.func @test_assumed_rank(%arg0: !fir.box<!fir.array<*:f32>>) -> index {
%0 = fir.box_total_elements %arg0 : (!fir.box<!fir.array<*:f32>>) -> index
return %0 : index
}
// ALL-LABEL: func.func @test_assumed_rank(
// ALL-SAME: %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: !fir.box<!fir.array<*:f32>>) -> index {
// ALL: %[[VAL_3:.*]] = arith.constant {{.*}} : i32
// ALL: %[[VAL_1:.*]] = fir.address_of({{.*}}) : !fir.ref<!fir.char<1,{{.*}}>>
// ALL: %[[VAL_4:.*]] = fir.convert %[[VAL_0]] : (!fir.box<!fir.array<*:f32>>) -> !fir.box<none>
// ALL: %[[VAL_5:.*]] = fir.convert %[[VAL_1]] : (!fir.ref<!fir.char<1,{{.*}}>>) -> !fir.ref<i8>
// ALL: %[[VAL_6:.*]] = fir.call @_FortranASize(%[[VAL_4]], %[[VAL_5]], %[[VAL_3]]) : (!fir.box<none>, !fir.ref<i8>, i32) -> i64
// ALL: %[[VAL_7:.*]] = fir.convert %[[VAL_6]] : (i64) -> index
// ALL: return %[[VAL_7]] : index
// ALL: }