[PATCH] D144534: [DAGCombine] Fold SETCC_OEQ(x, Inf) into IS_FPCLASS
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 27 02:58:08 PDT 2023
arsenm added inline comments.
================
Comment at: llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp:4969
+
+ if (isOperationLegalOrCustom(ISD::IS_FPCLASS, N0.getValueType())) {
+ bool IsFabs = N0.getOpcode() == ISD::FABS;
----------------
Is the advantage that you avoid materializing the inf constant? Can you check if the constantfp is legal?
================
Comment at: llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp:4972
+ SDValue Op = IsFabs ? N0.getOperand(0) : N0;
+ if (Cond == ISD::SETOEQ && CFP->isInfinity()) {
+ FPClassTest Flag = CFP->isNegative() ? (IsFabs ? fcNone : fcNegInf)
----------------
Could also handle the unordered case
================
Comment at: llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp:4976
+ return DAG.getNode(ISD::IS_FPCLASS, dl, VT, Op,
+ DAG.getConstant(Flag, dl, MVT::i32, true));
+ }
----------------
getTargetConstant
================
Comment at: llvm/test/CodeGen/AMDGPU/fp-classify.ll:616
+; SI-NEXT: v_cvt_f32_f16_e64 v1, |s0|
+; SI-NEXT: v_cmp_class_f32_e32 vcc, v1, v0
; SI-NEXT: v_cndmask_b32_e64 v0, 0, 1, vcc
----------------
The result is the same but I’d somewhat prefer to keep the original isa. The infinity constant is more likely reusable with other uses in the program
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D144534/new/
https://reviews.llvm.org/D144534
More information about the llvm-commits
mailing list