llvm.org GIT mirror llvm / 6ae1bfa
AMDGPU: Handle some vector operations in isCanonicalized git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339077 91177308-0d34-0410-b5e6-96231b3b80d8 Matt Arsenault 1 year, 6 months ago
2 changed file(s) with 104 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
68426842 return isCanonicalized(DAG, Op.getOperand(1), MaxDepth - 1) &&
68436843 isCanonicalized(DAG, Op.getOperand(2), MaxDepth - 1);
68446844 }
6845 case ISD::BUILD_VECTOR: {
6846 for (unsigned i = 0, e = Op.getNumOperands(); i != e; ++i) {
6847 SDValue SrcOp = Op.getOperand(i);
6848 if (!isCanonicalized(DAG, SrcOp, MaxDepth - 1))
6849 return false;
6850 }
6851
6852 return true;
6853 }
6854 case ISD::EXTRACT_VECTOR_ELT:
6855 case ISD::EXTRACT_SUBVECTOR: {
6856 return isCanonicalized(DAG, Op.getOperand(0), MaxDepth - 1);
6857 }
6858 case ISD::INSERT_VECTOR_ELT: {
6859 return isCanonicalized(DAG, Op.getOperand(0), MaxDepth - 1) &&
6860 isCanonicalized(DAG, Op.getOperand(1), MaxDepth - 1);
6861 }
6862 case ISD::UNDEF:
6863 // Could be anything.
6864 return false;
68456865 default:
68466866 return denormalsEnabledForType(Op.getValueType()) &&
68476867 DAG.isKnownNeverSNaN(Op);
740740 %v = tail call float @llvm.minnum.f32(float %arg0, float %arg1)
741741 %canonicalized = tail call float @llvm.canonicalize.f32(float %v)
742742 ret float %canonicalized
743 }
744
745 ; GCN-LABEL: {{^}}v_test_canonicalize_build_vector_v2f16:
746 ; GFX9-DAG: v_add_f16_e32
747 ; GFX9-DAG: v_mul_f16_e32
748 ; GFX9-NOT: v_max
749 ; GFX9-NOT: v_pk_max
750 define <2 x half> @v_test_canonicalize_build_vector_v2f16(<2 x half> %vec) {
751 %lo = extractelement <2 x half> %vec, i32 0
752 %hi = extractelement <2 x half> %vec, i32 1
753 %lo.op = fadd half %lo, 1.0
754 %hi.op = fmul half %lo, 4.0
755 %ins0 = insertelement <2 x half> undef, half %lo.op, i32 0
756 %ins1 = insertelement <2 x half> %ins0, half %hi.op, i32 1
757 %canonicalized = call <2 x half> @llvm.canonicalize.v2f16(<2 x half> %ins1)
758 ret <2 x half> %canonicalized
759 }
760
761 ; GCN-LABEL: {{^}}v_test_canonicalize_build_vector_noncanon1_v2f16:
762 ; GFX9: v_add_f16_e32
763 ; GFX9: v_pk_max
764 define <2 x half> @v_test_canonicalize_build_vector_noncanon1_v2f16(<2 x half> %vec) {
765 %lo = extractelement <2 x half> %vec, i32 0
766 %lo.op = fadd half %lo, 1.0
767 %ins = insertelement <2 x half> %vec, half %lo.op, i32 0
768 %canonicalized = call <2 x half> @llvm.canonicalize.v2f16(<2 x half> %ins)
769 ret <2 x half> %canonicalized
770 }
771
772 ; GCN-LABEL: {{^}}v_test_canonicalize_build_vector_noncanon0_v2f16:
773 ; GFX9: v_add_f16_sdwa
774 ; GFX9: v_pk_max
775 define <2 x half> @v_test_canonicalize_build_vector_noncanon0_v2f16(<2 x half> %vec) {
776 %hi = extractelement <2 x half> %vec, i32 1
777 %hi.op = fadd half %hi, 1.0
778 %ins = insertelement <2 x half> %vec, half %hi.op, i32 1
779 %canonicalized = call <2 x half> @llvm.canonicalize.v2f16(<2 x half> %ins)
780 ret <2 x half> %canonicalized
781 }
782
783 ; GCN-LABEL: {{^}}v_test_canonicalize_extract_element_v2f16:
784 ; GFX9: s_waitcnt
785 ; GFX9-NEXT: v_pk_mul_f16 v0, v0, 4.0 op_sel_hi:[1,0]
786 ; GFX9-NEXT: s_setpc_b64
787 define half @v_test_canonicalize_extract_element_v2f16(<2 x half> %vec) {
788 %vec.op = fmul <2 x half> %vec,
789 %elt = extractelement <2 x half> %vec.op, i32 0
790 %canonicalized = call half @llvm.canonicalize.f16(half %elt)
791 ret half %canonicalized
792 }
793
794 ; GCN-LABEL: {{^}}v_test_canonicalize_insertelement_v2f16:
795 ; GFX9: v_pk_mul_f16
796 ; GFX9: v_mul_f16_e32
797 ; GFX9-NOT: v_max
798 ; GFX9-NOT: v_pk_max
799 define <2 x half> @v_test_canonicalize_insertelement_v2f16(<2 x half> %vec, half %val, i32 %idx) {
800 %vec.op = fmul <2 x half> %vec,
801 %ins.op = fmul half %val, 8.0
802 %ins = insertelement <2 x half> %vec.op, half %ins.op, i32 %idx
803 %canonicalized = call <2 x half> @llvm.canonicalize.v2f16(<2 x half> %ins)
804 ret <2 x half> %canonicalized
805 }
806
807 ; GCN-LABEL: {{^}}v_test_canonicalize_insertelement_noncanon_vec_v2f16:
808 ; GFX9: v_mul_f16
809 ; GFX9: v_pk_max_f16 v0, v0, v0
810 ; GFX9-NEXT: s_setpc_b64
811 define <2 x half> @v_test_canonicalize_insertelement_noncanon_vec_v2f16(<2 x half> %vec, half %val, i32 %idx) {
812 %ins.op = fmul half %val, 8.0
813 %ins = insertelement <2 x half> %vec, half %ins.op, i32 %idx
814 %canonicalized = call <2 x half> @llvm.canonicalize.v2f16(<2 x half> %ins)
815 ret <2 x half> %canonicalized
816 }
817
818 ; GCN-LABEL: {{^}}v_test_canonicalize_insertelement_noncanon_insval_v2f16:
819 ; GFX9: v_pk_mul_f16
820 ; GFX9: v_pk_max_f16 v0, v0, v0
821 ; GFX9-NEXT: s_setpc_b64
822 define <2 x half> @v_test_canonicalize_insertelement_noncanon_insval_v2f16(<2 x half> %vec, half %val, i32 %idx) {
823 %vec.op = fmul <2 x half> %vec,
824 %ins = insertelement <2 x half> %vec.op, half %val, i32 %idx
825 %canonicalized = call <2 x half> @llvm.canonicalize.v2f16(<2 x half> %ins)
826 ret <2 x half> %canonicalized
743827 }
744828
745829 ; Avoid failing the test on FreeBSD11.0 which will match the GCN-NOT: 1.0