Files
TheRock/compiler/amd-llvm/clang/test/CIR/CodeGen/int-to-bool.cpp
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

75 lines
2.3 KiB
C++

// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-cir %s -o %t.cir
// RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-llvm %s -o %t-cir.ll
// RUN: FileCheck --input-file=%t-cir.ll %s -check-prefix=LLVM
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -emit-llvm %s -o %t.ll
// RUN: FileCheck --input-file=%t.ll %s -check-prefix=OGCG
bool f1(unsigned char c) {
return c;
}
// CIR: cir.func{{.*}} @_Z2f1h
// CIR: cir.cast int_to_bool %{{.*}} : !u8i -> !cir.bool
// Note: The full zext/store/load/trunc sequence is checked here to show what
// CIR is being lowered to. There's no need to check it for every function since
// the lowering is the same for all of them.
// LLVM: define{{.*}} i1 @_Z2f1h
// LLVM: %[[CMP:.*]] = icmp ne i8 %4, 0
// LLVM: %[[ZEXT:.*]] = zext i1 %[[CMP]] to i8
// LLVM: store i8 %[[ZEXT]], ptr %{{.*}}
// LLVM: %[[LOAD:.*]] = load i8, ptr %{{.*}}
// LLVM: %[[TRUNC:.*]] = trunc i8 %[[LOAD]] to i1
// LLVM: ret i1 %[[TRUNC]]
// OGCG: define{{.*}} i1 @_Z2f1h
// OGCG: %[[CMP:.*]] = icmp ne i8 %{{.*}}, 0
// OGCG: ret i1 %[[CMP]]
bool f2(short s) {
return s;
}
// CIR: cir.func{{.*}} @_Z2f2s
// CIR: cir.cast int_to_bool %{{.*}} : !s16i -> !cir.bool
// LLVM: define{{.*}} i1 @_Z2f2s
// LLVM: %[[CMP:.*]] = icmp ne i16 %4, 0
// LLVM: %[[ZEXT:.*]] = zext i1 %[[CMP]] to i8
// OGCG: define{{.*}} i1 @_Z2f2s
// OGCG: %[[CMP:.*]] = icmp ne i16 %{{.*}}, 0
// OGCG: ret i1 %[[CMP]]
bool f3(unsigned u) {
return u;
}
// CIR: cir.func{{.*}} @_Z2f3j
// CIR: cir.cast int_to_bool %{{.*}} : !u32i -> !cir.bool
// LLVM: define{{.*}} i1 @_Z2f3j
// LLVM: %[[CMP:.*]] = icmp ne i32 %4, 0
// LLVM: %[[ZEXT:.*]] = zext i1 %[[CMP]] to i8
// OGCG: define{{.*}} i1 @_Z2f3j
// OGCG: %[[CMP:.*]] = icmp ne i32 %{{.*}}, 0
// OGCG: ret i1 %[[CMP]]
bool f4(long l) {
return l;
}
// CIR: cir.func{{.*}} @_Z2f4l
// CIR: cir.cast int_to_bool %{{.*}} : !s64i -> !cir.bool
// LLVM: define{{.*}} i1 @_Z2f4l
// LLVM: %[[CMP:.*]] = icmp ne i64 %4, 0
// LLVM: %[[ZEXT:.*]] = zext i1 %[[CMP]] to i8
// OGCG: define{{.*}} i1 @_Z2f4l
// OGCG: %[[CMP:.*]] = icmp ne i64 %{{.*}}, 0
// OGCG: ret i1 %[[CMP]]