[PATCH] D18593: [PowerPC] Front end improvements for vec_splat
amehsan via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 1 08:52:30 PDT 2016
amehsan added a comment.
Thanks for using target-independent builtin and IR.
================
Comment at: lib/Headers/altivec.h:7726-7736
@@ -7725,7 +7725,13 @@
vec_splat(vector signed int __a, unsigned const int __b) {
- unsigned char b0 = (__b & 0x03) * 4;
- unsigned char b1 = b0 + 1, b2 = b0 + 2, b3 = b0 + 3;
- return vec_perm(__a, __a,
- (vector unsigned char)(b0, b1, b2, b3, b0, b1, b2, b3, b0, b1,
- b2, b3, b0, b1, b2, b3));
+ const unsigned __elem = __b & 0x3;
+ switch(__elem) {
+ case 0:
+ return __builtin_shufflevector(__a, __a, 0, 0, 0, 0);
+ case 1:
+ return __builtin_shufflevector(__a, __a, 1, 1, 1, 1);
+ case 2:
+ return __builtin_shufflevector(__a, __a, 2, 2, 2, 2);
+ case 3:
+ return __builtin_shufflevector(__a, __a, 3, 3, 3, 3);
+ }
}
----------------
Why do we need a switch case here (and in the ones below) instead of just returning __builtin_shufflevector(__a, __a, __elem, __elem, __elem, __elem)?
Repository:
rL LLVM
http://reviews.llvm.org/D18593
More information about the llvm-commits
mailing list