1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00

[ConstantFolding] Fix constant folding for vector cttz and ctlz intrinsics to understand that the second argument is still a scalar.

llvm-svn: 304668
This commit is contained in:
Craig Topper 2017-06-03 18:50:29 +00:00
parent c04a5f29d7
commit e9a9480241
3 changed files with 10 additions and 6 deletions

View File

@ -2034,6 +2034,13 @@ Constant *ConstantFoldVectorCall(StringRef Name, unsigned IntrinsicID,
for (unsigned I = 0, E = VTy->getNumElements(); I != E; ++I) {
// Gather a column of constants.
for (unsigned J = 0, JE = Operands.size(); J != JE; ++J) {
// These intrinsics use a scalar type for their second argument.
if (J == 1 &&
(IntrinsicID == Intrinsic::cttz || IntrinsicID == Intrinsic::ctlz)) {
Lane[J] = Operands[J];
continue;
}
Constant *Agg = Operands[J]->getAggregateElement(I);
if (!Agg)
return nullptr;

View File

@ -537,8 +537,7 @@ define i32 @ctlz_undef(i32 %Value) {
define <2 x i32> @ctlz_undef_vec(<2 x i32> %Value) {
; CHECK-LABEL: @ctlz_undef_vec(
; CHECK-NEXT: [[CTLZ:%.*]] = call <2 x i32> @llvm.ctlz.v2i32(<2 x i32> zeroinitializer, i1 true)
; CHECK-NEXT: ret <2 x i32> [[CTLZ]]
; CHECK-NEXT: ret <2 x i32> undef
;
%ctlz = call <2 x i32> @llvm.ctlz.v2i32(<2 x i32> zeroinitializer, i1 true)
ret <2 x i32> %ctlz
@ -575,8 +574,7 @@ define i32 @cttz_undef(i32 %Value) nounwind {
define <2 x i32> @cttz_undef_vec(<2 x i32> %Value) nounwind {
; CHECK-LABEL: @cttz_undef_vec(
; CHECK-NEXT: [[CTTZ:%.*]] = call <2 x i32> @llvm.cttz.v2i32(<2 x i32> zeroinitializer, i1 true)
; CHECK-NEXT: ret <2 x i32> [[CTTZ]]
; CHECK-NEXT: ret <2 x i32> undef
;
%cttz = call <2 x i32> @llvm.cttz.v2i32(<2 x i32> zeroinitializer, i1 true)
ret <2 x i32> %cttz

View File

@ -203,8 +203,7 @@ declare <2 x i256> @llvm.cttz.v2i256(<2 x i256> %src, i1 %is_zero_undef)
define <2 x i256> @test_cttz_vec() {
; CHECK-LABEL: @test_cttz_vec(
; CHECK-NEXT: [[X:%.*]] = call <2 x i256> @llvm.cttz.v2i256(<2 x i256> <i256 10, i256 10>, i1 false)
; CHECK-NEXT: ret <2 x i256> [[X]]
; CHECK-NEXT: ret <2 x i256> <i256 1, i256 1>
;
%x = call <2 x i256> @llvm.cttz.v2i256(<2 x i256> <i256 10, i256 10>, i1 false)
ret <2 x i256> %x