Index: lib/Headers/altivec.h =================================================================== --- lib/Headers/altivec.h +++ lib/Headers/altivec.h @@ -7664,13 +7664,15 @@ static __inline__ vector unsigned int __ATTRS_o_ai vec_rlnm(vector unsigned int __a, vector unsigned int __b, vector unsigned int __c) { - return __builtin_altivec_vrlwnm(__a, __b) & __c; + vector unsigned int OneByte = { 0x8, 0x8, 0x8, 0x8 }; + return __builtin_altivec_vrlwnm(__a, ((__c << OneByte) | __b)); } static __inline__ vector unsigned long long __ATTRS_o_ai vec_rlnm(vector unsigned long long __a, vector unsigned long long __b, vector unsigned long long __c) { - return __builtin_altivec_vrldnm(__a, __b) & __c; + vector unsigned long long OneByte = { 0x8, 0x8 }; + return __builtin_altivec_vrldnm(__a, ((__c << OneByte) | __b)); } #endif Index: test/CodeGen/builtins-ppc-p9vector.c =================================================================== --- test/CodeGen/builtins-ppc-p9vector.c +++ test/CodeGen/builtins-ppc-p9vector.c @@ -868,20 +868,24 @@ return vec_rlmi(vula, vula, vula); } vector unsigned int test77(void) { +// CHECK-BE: %shl.i = shl <4 x i32 +// CHECK-BE: %or.i = or <4 x i32> %shl.i // CHECK-BE: @llvm.ppc.altivec.vrlwnm(<4 x i32 -// CHECK-BE: and <4 x i32 // CHECK-BE: ret <4 x i32> +// CHECK: %shl.i = shl <4 x i32 +// CHECK: %or.i = or <4 x i32> %shl.i // CHECK: @llvm.ppc.altivec.vrlwnm(<4 x i32 -// CHECK: and <4 x i32 // CHECK: ret <4 x i32> return vec_rlnm(vuia, vuia, vuia); } vector unsigned long long test78(void) { +// CHECK-BE: %shl.i = shl <2 x i64 +// CHECK-BE: %or.i = or <2 x i64> %shl.i // CHECK-BE: @llvm.ppc.altivec.vrldnm(<2 x i64 -// CHECK-BE: and <2 x i64 // CHECK-BE-NEXT: ret <2 x i64> +// CHECK: %shl.i = shl <2 x i64 +// CHECK: %or.i = or <2 x i64> %shl.i // CHECK: @llvm.ppc.altivec.vrldnm(<2 x i64 -// CHECK: and <2 x i64 // CHECK-NEXT: ret <2 x i64> return vec_rlnm(vula, vula, vula); }