[llvm] [DAG] Fixing the non-optimal code with the following: `select i1 %0, float 1.0, float 0.0`. (PR #107732)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 9 01:36:05 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)) {
----------------
RKSimon wrote:
This could either be added to combineSelectOfTwoConstants (which is currently integer-only), or we start a similar combineSelectOfTwoFPConstants
https://github.com/llvm/llvm-project/pull/107732
More information about the llvm-commits
mailing list