llvm-project/clang/test/CodeGen/PowerPC/ppc-vector-compare.cpp
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

35 lines
1007 B
C++

// RUN: %clang_cc1 -flax-vector-conversions=none -target-feature +vsx -triple powerpc64-unknown-unknown -emit-llvm %s \
// RUN: -o - | FileCheck %s
#include <altivec.h>
// CHECK-LABEL: @_Z5test1Dv8_tS_
// CHECK: @llvm.ppc.altivec.vcmpequh.p
bool test1(vector unsigned short v1, vector unsigned short v2) {
return v1 == v2;
}
// CHECK-LABEL: @_Z5test2Dv2_mS_Dv2_lS0_Dv2_yS1_Dv2_xS2_Dv2_dS3_
bool test2(vector unsigned long v1, vector unsigned long v2,
vector long v3, vector long v4,
vector unsigned long long v5, vector unsigned long long v6,
vector long long v7, vector long long v8,
vector double v9, vector double v10) {
// CHECK: @llvm.ppc.altivec.vcmpequd.p
bool res = v1 == v2;
// CHECK: @llvm.ppc.altivec.vcmpequd.p
res |= v3 == v4;
// CHECK: @llvm.ppc.altivec.vcmpequd.p
res |= v5 == v6;
// CHECK: @llvm.ppc.altivec.vcmpequd.p
res |= v7 == v8;
// CHECK: @llvm.ppc.vsx.xvcmpeqdp.p
res |= v9 == v10;
return res;
}