Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Power10] Implement custom codegen for the vec_replace_elt and vec_re…
…place_unaligned builtins. This patch implements custom codegen for the vec_replace_elt and vec_replace_unaligned builtins. These builtins map to the @llvm.ppc.altivec.vinsw and @llvm.ppc.altivec.vinsd intrinsics depending on the arguments. The main motivation for doing custom codegen for these intrinsics is because there are float and double versions of the builtin. Normally, the converting the float to an integer would be done via fptoui in the IR. This is incorrect as fptoui truncates the value and we must ensure the value is not truncated. Therefore, we provide custom codegen to utilize bitcast instead as bitcasts do not truncate. Differential Revision: https://reviews.llvm.org/D83500
- Loading branch information
Showing
6 changed files
with
290 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// REQUIRES: powerpc-registered-target | ||
|
||
// RUN: %clang_cc1 -target-feature +vsx -target-cpu pwr10 \ | ||
// RUN: -triple powerpc64le-unknown-unknown -fsyntax-only %s -verify | ||
// RUN: %clang_cc1 -target-feature +vsx -target-cpu pwr10 \ | ||
// RUN: -triple powerpc64-unknown-unknown -fsyntax-only %s -verify | ||
|
||
#include <altivec.h> | ||
|
||
vector signed int vsia; | ||
vector unsigned int vuia; | ||
vector signed long long vslla; | ||
vector unsigned long long vulla; | ||
vector float vfa; | ||
vector double vda; | ||
signed int sia; | ||
unsigned int uia; | ||
signed long long slla; | ||
unsigned long long ulla; | ||
float fa; | ||
double da; | ||
|
||
vector signed int test_vec_replace_elt_si(void) { | ||
return vec_replace_elt(vsia, sia, 13); // expected-error {{argument value 13 is outside the valid range [0, 12]}} | ||
} | ||
|
||
vector unsigned int test_vec_replace_elt_ui(void) { | ||
return vec_replace_elt(vuia, sia, 1); // expected-error {{arguments are of different types ('unsigned int' vs 'int')}} | ||
} | ||
|
||
vector float test_vec_replace_elt_f(void) { | ||
return vec_replace_elt(vfa, fa, 20); // expected-error {{argument value 20 is outside the valid range [0, 12]}} | ||
} | ||
|
||
vector float test_vec_replace_elt_f_2(void) { | ||
return vec_replace_elt(vfa, da, 0); // expected-error {{arguments are of different types ('float' vs 'double')}} | ||
} | ||
|
||
vector signed long long test_vec_replace_elt_sll(void) { | ||
return vec_replace_elt(vslla, slla, 9); // expected-error {{argument value 9 is outside the valid range [0, 8]}} | ||
} | ||
|
||
vector unsigned long long test_vec_replace_elt_ull(void) { | ||
return vec_replace_elt(vulla, vda, 0); // expected-error {{arguments are of different types ('unsigned long long' vs '__vector double' (vector of 2 'double' values))}} | ||
} | ||
|
||
vector unsigned long long test_vec_replace_elt_ull_2(void) { | ||
return vec_replace_elt(vulla, vulla, vsia); // expected-error {{argument to '__builtin_altivec_vec_replace_elt' must be a constant integer}} | ||
} | ||
|
||
vector double test_vec_replace_elt_d(void) { | ||
return vec_replace_elt(vda, da, 33); // expected-error {{argument value 33 is outside the valid range [0, 8]}} | ||
} | ||
|
||
vector unsigned char test_vec_replace_unaligned_si(void) { | ||
return vec_replace_unaligned(vsia, da, 6); // expected-error {{arguments are of different types ('int' vs 'double')}} | ||
} | ||
|
||
vector unsigned char test_vec_replace_unaligned_ui(void) { | ||
return vec_replace_unaligned(vuia, uia, 14); // expected-error {{argument value 14 is outside the valid range [0, 12]}} | ||
} | ||
|
||
vector unsigned char test_vec_replace_unaligned_f(void) { | ||
return vec_replace_unaligned(vfa, fa, 19); // expected-error {{argument value 19 is outside the valid range [0, 12]}} | ||
} | ||
|
||
vector unsigned char test_vec_replace_unaligned_sll(void) { | ||
return vec_replace_unaligned(vslla, fa, 0); // expected-error {{arguments are of different types ('long long' vs 'float')}} | ||
} | ||
|
||
vector unsigned char test_vec_replace_unaligned_ull(void) { | ||
return vec_replace_unaligned(vulla, ulla, 12); // expected-error {{argument value 12 is outside the valid range [0, 8]}} | ||
} | ||
|
||
vector unsigned char test_vec_replace_unaligned_d(void) { | ||
return vec_replace_unaligned(vda, fa, 8); // expected-error {{arguments are of different types ('double' vs 'float')}} | ||
} | ||
|
||
vector unsigned char test_vec_replace_unaligned_d_2(void) { | ||
return vec_replace_unaligned(vda, vda, da); // expected-error {{argument to '__builtin_altivec_vec_replace_unaligned' must be a constant integer}} | ||
} |