Files
TheRock/compiler/amd-llvm/clang/test/CIR/CodeGenBuiltins/builtin-rotate.c
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

119 lines
3.7 KiB
C

// RUN: %clang_cc1 -triple aarch64-none-linux-android21 -fclangir -emit-cir %s -o %t.cir
// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
// RUN: %clang_cc1 -triple aarch64-none-linux-android21 -fclangir -emit-llvm %s -o %t-cir.ll
// RUN: FileCheck --check-prefix=LLVM --input-file=%t-cir.ll %s
// RUN: %clang_cc1 -triple aarch64-none-linux-android21 -emit-llvm %s -o %t.ll
// RUN: FileCheck --check-prefix=OGCG --input-file=%t.ll %s
void f() {
// CIR-LABEL: @f
// LLVM-LABEL: @f
// OGCG-LABEL: @f
unsigned int v[4];
unsigned int h = __builtin_rotateleft32(v[0], 1);
// CIR: %[[CONST:.*]] = cir.const #cir.int<1> : !u32i
// CIR: cir.rotate left {{.*}}, %[[CONST]] : !u32i
// LLVM: %[[SRC:.*]] = load i32, ptr
// LLVM: call i32 @llvm.fshl.i32(i32 %[[SRC]], i32 %[[SRC]], i32 1)
// OGCG: %[[SRC:.*]] = load i32, ptr
// OGCG: call i32 @llvm.fshl.i32(i32 %[[SRC]], i32 %[[SRC]], i32 1)
}
unsigned char rotl8(unsigned char x, unsigned char y) {
// CIR-LABEL: rotl8
// CIR: cir.rotate left {{.*}}, {{.*}} : !u8i
// LLVM-LABEL: rotl8
// LLVM: [[F:%.*]] = call i8 @llvm.fshl.i8(i8 [[X:%.*]], i8 [[X]], i8 [[Y:%.*]])
// OGCG-LABEL: rotl8
// OGCG: call i8 @llvm.fshl.i8(i8 {{.*}}, i8 {{.*}}, i8 {{.*}})
return __builtin_rotateleft8(x, y);
}
short rotl16(short x, short y) {
// CIR-LABEL: rotl16
// CIR: cir.rotate left {{.*}}, {{.*}} : !u16i
// LLVM-LABEL: rotl16
// LLVM: [[F:%.*]] = call i16 @llvm.fshl.i16(i16 [[X:%.*]], i16 [[X]], i16 [[Y:%.*]])
// OGCG-LABEL: rotl16
// OGCG: call i16 @llvm.fshl.i16(i16 {{.*}}, i16 {{.*}}, i16 {{.*}})
return __builtin_rotateleft16(x, y);
}
int rotl32(int x, unsigned int y) {
// CIR-LABEL: rotl32
// CIR: cir.rotate left {{.*}}, {{.*}} : !u32i
// LLVM-LABEL: rotl32
// LLVM: [[F:%.*]] = call i32 @llvm.fshl.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]])
// OGCG-LABEL: rotl32
// OGCG: call i32 @llvm.fshl.i32(i32 {{.*}}, i32 {{.*}}, i32 {{.*}})
return __builtin_rotateleft32(x, y);
}
unsigned long long rotl64(unsigned long long x, long long y) {
// CIR-LABEL: rotl64
// CIR: cir.rotate left {{.*}}, {{.*}} : !u64i
// LLVM-LABEL: rotl64
// LLVM: [[F:%.*]] = call i64 @llvm.fshl.i64(i64 [[X:%.*]], i64 [[X]], i64 [[Y:%.*]])
// OGCG-LABEL: rotl64
// OGCG: call i64 @llvm.fshl.i64(i64 {{.*}}, i64 {{.*}}, i64 {{.*}})
return __builtin_rotateleft64(x, y);
}
char rotr8(char x, char y) {
// CIR-LABEL: rotr8
// CIR: cir.rotate right {{.*}}, {{.*}} : !u8i
// LLVM-LABEL: rotr8
// LLVM: [[F:%.*]] = call i8 @llvm.fshr.i8(i8 [[X:%.*]], i8 [[X]], i8 [[Y:%.*]])
// OGCG-LABEL: rotr8
// OGCG: call i8 @llvm.fshr.i8(i8 {{.*}}, i8 {{.*}}, i8 {{.*}})
return __builtin_rotateright8(x, y);
}
unsigned short rotr16(unsigned short x, unsigned short y) {
// CIR-LABEL: rotr16
// CIR: cir.rotate right {{.*}}, {{.*}} : !u16i
// LLVM-LABEL: rotr16
// LLVM: [[F:%.*]] = call i16 @llvm.fshr.i16(i16 [[X:%.*]], i16 [[X]], i16 [[Y:%.*]])
// OGCG-LABEL: rotr16
// OGCG: call i16 @llvm.fshr.i16(i16 {{.*}}, i16 {{.*}}, i16 {{.*}})
return __builtin_rotateright16(x, y);
}
unsigned int rotr32(unsigned int x, int y) {
// CIR-LABEL: rotr32
// CIR: cir.rotate right {{.*}}, {{.*}} : !u32i
// LLVM-LABEL: rotr32
// LLVM: [[F:%.*]] = call i32 @llvm.fshr.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]])
// OGCG-LABEL: rotr32
// OGCG: call i32 @llvm.fshr.i32(i32 {{.*}}, i32 {{.*}}, i32 {{.*}})
return __builtin_rotateright32(x, y);
}
long long rotr64(long long x, unsigned long long y) {
// CIR-LABEL: rotr64
// CIR: cir.rotate right {{.*}}, {{.*}} : !u64i
// LLVM-LABEL: rotr64
// LLVM: [[F:%.*]] = call i64 @llvm.fshr.i64(i64 [[X:%.*]], i64 [[X]], i64 [[Y:%.*]])
// OGCG-LABEL: rotr64
// OGCG: call i64 @llvm.fshr.i64(i64 {{.*}}, i64 {{.*}}, i64 {{.*}})
return __builtin_rotateright64(x, y);
}