[llvm] [X86] Fold concat(PCMP*(), PCMP*()) -> CMPPS(concat, concat) on AVX1 targets (PR #95915)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 18 10:29:31 PDT 2024


================
@@ -55716,6 +55716,38 @@ static SDValue combineVectorCompare(SDNode *N, SelectionDAG &DAG,
   return SDValue();
 }
 
+// Helper to determine if we can convert an integer comparison to a float
+// comparison byt casting the operands.
+static std::optional<unsigned> CastIntSETCCtoFP(MVT VT, ISD::CondCode CC,
+                                                const KnownBits &LHS,
+                                                const KnownBits &RHS) {
+  MVT SVT = VT.getScalarType();
+  assert(SVT == MVT::f32 && "Only tested for float so far");
+  const fltSemantics &Sem = SelectionDAG::EVTToAPFloatSemantics(SVT);
+  assert((CC == ISD::SETEQ || CC == ISD::SETGT) &&
+         "Only PCMPEQ/PCMPGT currently supported");
+
+  // TODO: Handle bitcastable integers.
+
+  // For cvt + signed compare we need:
+  // abs(lhs) < MaxConvertableCvt and abs(rhs) < MaxConvertableCvt
+  auto OpInAbsRange = [](const KnownBits &Known, const APInt &Bound) {
+    if (Known.isUnknown() ||
+        !KnownBits::slt(Known, KnownBits::makeConstant(Bound)) ||
+        !KnownBits::sgt(Known, KnownBits::makeConstant(-Bound)))
----------------
goldsteinn wrote:

Think the unsigned version is clearer

https://github.com/llvm/llvm-project/pull/95915


More information about the llvm-commits mailing list