[llvm] [DAG] Fixing the non-optimal code with the following: `select i1 %0, float 1.0, float 0.0`. (PR #107732)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 8 21:13:28 PDT 2024


================
@@ -24150,6 +24150,13 @@ SDValue X86TargetLowering::LowerSELECT(SDValue Op, SelectionDAG &DAG) const {
                                           DAG.getBitcast(NVT, Op2)));
   }
 
+  // (select cc, 1.0, 0.0) -> (sint_to_fp (zext cc))
+  const ConstantFPSDNode *FPTV = dyn_cast<ConstantFPSDNode>(Op1);
+  const ConstantFPSDNode *FPFV = dyn_cast<ConstantFPSDNode>(Op2);
+  if (FPTV && FPFV && FPTV->isExactlyValue(1.0) && FPFV->isExactlyValue(0.0)) {
----------------
arsenm wrote:

This probably should be an optimization combine, and not in the lowering. Could also be in generic combiner if the constants aren't legal 

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


More information about the llvm-commits mailing list