Files
TheRock/compiler/amd-llvm/flang/test/Transforms/constant-argument-globalisation-2.fir
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

99 lines
2.8 KiB
Plaintext

// RUN: fir-opt --split-input-file --constant-argument-globalisation-opt < %s | FileCheck %s
module {
// Test for "two conditional writes to the same alloca doesn't get replaced."
func.func @func(%arg0: i32, %arg1: i1) {
%c2_i32 = arith.constant 2 : i32
%addr = fir.alloca i32 {adapt.valuebyref}
fir.if %arg1 {
fir.store %c2_i32 to %addr : !fir.ref<i32>
} else {
fir.store %arg0 to %addr : !fir.ref<i32>
}
fir.call @sub2(%addr) : (!fir.ref<i32>) -> ()
return
}
func.func private @sub2(!fir.ref<i32>)
// CHECK-LABEL: func.func @func
// CHECK-SAME: [[ARG0:%.*]]: i32
// CHECK-SAME: [[ARG1:%.*]]: i1)
// CHECK: [[CONST:%.*]] = arith.constant
// CHECK: [[ADDR:%.*]] = fir.alloca i32
// CHECK: fir.if [[ARG1]]
// CHECK: fir.store [[CONST]] to [[ADDR]]
// CHECK: } else {
// CHECK: fir.store [[ARG0]] to [[ADDR]]
// CHECK: fir.call @sub2([[ADDR]])
// CHECK: return
}
// -----
module {
// Test for "two writes to the same alloca doesn't get replaced."
func.func @func() {
%c1_i32 = arith.constant 1 : i32
%c2_i32 = arith.constant 2 : i32
%addr = fir.alloca i32 {adapt.valuebyref}
fir.store %c1_i32 to %addr : !fir.ref<i32>
fir.store %c2_i32 to %addr : !fir.ref<i32>
fir.call @sub2(%addr) : (!fir.ref<i32>) -> ()
return
}
func.func private @sub2(!fir.ref<i32>)
// CHECK-LABEL: func.func @func
// CHECK: [[CONST1:%.*]] = arith.constant
// CHECK: [[CONST2:%.*]] = arith.constant
// CHECK: [[ADDR:%.*]] = fir.alloca i32
// CHECK: fir.store [[CONST1]] to [[ADDR]]
// CHECK: fir.store [[CONST2]] to [[ADDR]]
// CHECK: fir.call @sub2([[ADDR]])
// CHECK: return
}
// -----
module {
// Test for "one write to the the alloca gets replaced."
func.func @func() {
%c1_i32 = arith.constant 1 : i32
%addr = fir.alloca i32 {adapt.valuebyref}
fir.store %c1_i32 to %addr : !fir.ref<i32>
fir.call @sub2(%addr) : (!fir.ref<i32>) -> ()
return
}
func.func private @sub2(!fir.ref<i32>)
// CHECK-LABEL: func.func @func
// CHECK: [[ADDR:%.*]] = fir.address_of([[EXTR:@.*]]) : !fir.ref<i32>
// CHECK: fir.call @sub2([[ADDR]])
// CHECK: return
// CHECK: fir.global internal [[EXTR]] constant : i32 {
// CHECK: %{{.*}} = arith.constant 1 : i32
// CHECK: fir.has_value %{{.*}} : i32
// CHECK: }
}
// -----
// Check that same argument used twice is converted.
module {
func.func @func(%arg0: !fir.ref<i32>, %arg1: i1) {
%c2_i32 = arith.constant 2 : i32
%addr1 = fir.alloca i32 {adapt.valuebyref}
fir.store %c2_i32 to %addr1 : !fir.ref<i32>
fir.call @sub1(%addr1, %addr1) : (!fir.ref<i32>, !fir.ref<i32>) -> ()
return
}
}
// CHECK-LABEL: func.func @func
// CHECK-NEXT: %[[ARG1:.*]] = fir.address_of([[CONST1:@.*]]) : !fir.ref<i32>
// CHECK-NEXT: %[[ARG2:.*]] = fir.address_of([[CONST2:@.*]]) : !fir.ref<i32>
// CHECK-NEXT: fir.call @sub1(%[[ARG1]], %[[ARG2]])
// CHECK-NEXT: return