[llvm] [X86][AVX10.2] Support AVX10.2-COMEF new instructions. (PR #108063)
Phoebe Wang via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 10 20:40:07 PDT 2024
================
@@ -26060,32 +26060,67 @@ SDValue X86TargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op,
if (CC == ISD::SETLT || CC == ISD::SETLE)
std::swap(LHS, RHS);
- SDValue Comi = DAG.getNode(IntrData->Opc0, dl, MVT::i32, LHS, RHS);
+ // For AVX10.2, Support EQ and NE
+ bool HasAVX10_2_COMX =
+ Subtarget.hasAVX10_2() && (CC == ISD::SETEQ || CC == ISD::SETNE);
+
+ // AVX10.2 COMPARE supports only v2f64, v4f32 or v8f16
+ auto SVT = LHS.getSimpleValueType();
+ bool HasAVX10_2_COMX_Ty =
+ (SVT == MVT::v2f64) || (SVT == MVT::v4f32) || (SVT == MVT::v8f16);
+
+ auto ComiOpCode = IntrData->Opc0;
+ auto isUnordered = (ComiOpCode == X86ISD::UCOMI);
+
+ if (HasAVX10_2_COMX && HasAVX10_2_COMX_Ty)
+ ComiOpCode = isUnordered ? X86ISD::UCOMX : X86ISD::COMX;
+
+ SDValue Comi = DAG.getNode(ComiOpCode, dl, MVT::i32, LHS, RHS);
+
SDValue SetCC;
- switch (CC) {
- case ISD::SETEQ: { // (ZF = 0 and PF = 0)
- SetCC = getSETCC(X86::COND_E, Comi, dl, DAG);
- SDValue SetNP = getSETCC(X86::COND_NP, Comi, dl, DAG);
- SetCC = DAG.getNode(ISD::AND, dl, MVT::i8, SetCC, SetNP);
- break;
- }
- case ISD::SETNE: { // (ZF = 1 or PF = 1)
- SetCC = getSETCC(X86::COND_NE, Comi, dl, DAG);
- SDValue SetP = getSETCC(X86::COND_P, Comi, dl, DAG);
- SetCC = DAG.getNode(ISD::OR, dl, MVT::i8, SetCC, SetP);
- break;
- }
----------------
phoebewang wrote:
ditto. Leave below unchanged.
https://github.com/llvm/llvm-project/pull/108063
More information about the llvm-commits
mailing list