DAG: Fix not legalizing vector fcanonicalizes

If an fcanoncialize was done on a vector type that was legal,

llvm-svn: 330981
This commit is contained in:
Matt Arsenault 2018-04-26 19:21:37 +00:00
parent fcc5ba46b7
commit 540512c297
3 changed files with 15 additions and 0 deletions

View File

@ -366,6 +366,7 @@ SDValue VectorLegalizer::LegalizeOp(SDValue Op) {
case ISD::UMAX:
case ISD::SMUL_LOHI:
case ISD::UMUL_LOHI:
case ISD::FCANONICALIZE:
QueryType = Node->getValueType(0);
break;
case ISD::FP_ROUND_INREG:

View File

@ -479,6 +479,7 @@ SITargetLowering::SITargetLowering(const TargetMachine &TM,
setOperationAction(ISD::FMA, MVT::v2f16, Legal);
setOperationAction(ISD::FMINNUM, MVT::v2f16, Legal);
setOperationAction(ISD::FMAXNUM, MVT::v2f16, Legal);
setOperationAction(ISD::FCANONICALIZE, MVT::v2f16, Legal);
// This isn't really legal, but this avoids the legalizer unrolling it (and
// allows matching fneg (fabs x) patterns)

View File

@ -7,6 +7,7 @@ declare double @llvm.canonicalize.f64(double) #0
declare half @llvm.canonicalize.f16(half) #0
declare <2 x half> @llvm.canonicalize.v2f16(<2 x half>) #0
declare i32 @llvm.amdgcn.workitem.id.x() #0
declare <2 x double> @llvm.canonicalize.v2f64(<2 x double>) #0
; GCN-LABEL: {{^}}v_test_canonicalize_var_f32:
; GCN: v_mul_f32_e32 [[REG:v[0-9]+]], 1.0, {{v[0-9]+}}
@ -528,6 +529,18 @@ define amdgpu_kernel void @test_canonicalize_value_v2f16_denorm(<2 x half> addrs
ret void
}
; GCN-LABEL: {{^}}v_test_canonicalize_var_v2f64:
; GCN: v_max_f64
; GCN: v_max_f64
define amdgpu_kernel void @v_test_canonicalize_var_v2f64(<2 x double> addrspace(1)* %out) #1 {
%tid = call i32 @llvm.amdgcn.workitem.id.x()
%gep = getelementptr <2 x double>, <2 x double> addrspace(1)* %out, i32 %tid
%val = load <2 x double>, <2 x double> addrspace(1)* %gep
%canonicalized = call <2 x double> @llvm.canonicalize.v2f64(<2 x double> %val)
store <2 x double> %canonicalized, <2 x double> addrspace(1)* %out
ret void
}
attributes #0 = { nounwind readnone }
attributes #1 = { nounwind }
attributes #2 = { nounwind "target-features"="-fp32-denormals,-fp64-fp16-denormals" }