llvm-project/clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-vec-error.c
Maryam Moghadas a9ddb7d54e [PowerPC] Fixing implicit castings in altivec for -fno-lax-vector-conversions
XL considers different vector types to be incompatible with each other.
For example assignment between variables of types vector float and vector
long long or even vector signed int and vector unsigned int are diagnosed.
clang, however does not diagnose such cases and does a simple bitcast between
the two types. This could easily result in program errors. This patch is to
fix the implicit casts in altivec.h so that there is no incompatible vector
type errors whit -fno-lax-vector-conversions, this is the prerequisite patch
to switch the default to -fno-lax-vector-conversions later.

Reviewed By: nemanjai, amyk

Differential Revision: https://reviews.llvm.org/D124093
2022-06-16 17:07:03 -05:00

27 lines
1.3 KiB
C

// REQUIRES: powerpc-registered-target
// RUN: %clang_cc1 -flax-vector-conversions=none -triple powerpc64-unknown-linux-gnu -fsyntax-only \
// RUN: -target-cpu pwr8 -Wall -Werror -verify %s
// RUN: %clang_cc1 -flax-vector-conversions=none -triple powerpc64le-unknown-linux-gnu -fsyntax-only \
// RUN: -target-cpu pwr8 -Wall -Werror -verify %s
// RUN: %clang_cc1 -flax-vector-conversions=none -triple powerpc64-unknown-aix -fsyntax-only \
// RUN: -target-cpu pwr8 -Wall -Werror -verify %s
// RUN: %clang_cc1 -flax-vector-conversions=none -triple powerpc-unknown-aix -fsyntax-only \
// RUN: -target-cpu pwr8 -Wall -Werror -verify %s
#include <altivec.h>
vector unsigned char test_ldrmb(char *ptr) {
return __vec_ldrmb(ptr, 17); // expected-error {{argument value 17 is outside the valid range [1, 16]}}
}
void test_strmb(char *ptr, vector unsigned char data) {
__vec_strmb(ptr, 17, data); // expected-error {{argument value 17 is outside the valid range [1, 16]}}
}
vector unsigned char test_ldrmbb(char *ptr) {
return __builtin_vsx_ldrmb(ptr, 17); // expected-error {{argument value 17 is outside the valid range [1, 16]}}
}
void test_strmbb(char *ptr, vector unsigned char data) {
__builtin_vsx_strmb(ptr, 17, data); // expected-error {{argument value 17 is outside the valid range [1, 16]}}
}