This is an archive of the discontinued LLVM Phabricator instance.

[DAG] Restrict (fp_round (copysign X, Y)) -> (copysign (fp_round X), Y) combine
ClosedPublic

Authored by reames on Apr 18 2023, 8:20 AM.

Details

Summary

This transformation creates an copysign node whose argument types do not match. RISCV does not handle such a case which results in a crash today. Looking at the relevant code in DAG, it looks like the process of enabling the non-matching types case was never completed for vectors at all. The transformation which triggered the RISCV crash is a specialization of another transform (specifically due to one use for profitability) which isn't enabled by default. Given that, I chose to match the preconditions for that other transform.

Other options here include:

  • Updating RISCV codegen to handle the mismatched argument type case for vectors. This is slightly tricky as I don't see an obvious profitable lowering for this case which doesn't involve simply adding back in the round/trunc.
  • Disabling the transform via a target hook.

This patch does involve two changes for AArch64 codegen. These could be called regressions, but well, the code after actually looks better than the code before.

Diff Detail

Event Timeline

reames created this revision.Apr 18 2023, 8:20 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 18 2023, 8:20 AM
reames requested review of this revision.Apr 18 2023, 8:20 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 18 2023, 8:20 AM
craig.topper added inline comments.Apr 18 2023, 10:02 AM
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
16615

Can we use XVT and YVT or XTy and YTy? VT or Ty are almost always in the variable names for SelectionDAG types.

reames updated this revision to Diff 514675.Apr 18 2023, 10:18 AM

Address reviewer comment.

This revision is now accepted and ready to land.Apr 18 2023, 10:21 AM
This revision was landed with ongoing or failed builds.Apr 18 2023, 10:37 AM
This revision was automatically updated to reflect the committed changes.