This is an archive of the discontinued LLVM Phabricator instance.

[x86] adjust cost model values for minnum/maxnum with fast-math-flags
ClosedPublic

Authored by spatel on Nov 30 2020, 11:19 AM.

Details

Summary

Without FMF, we lower these intrinsics into something like this:

vmaxsd	%xmm0, %xmm1, %xmm2
vcmpunordsd	%xmm0, %xmm0, %xmm0
vblendvpd	%xmm0, %xmm1, %xmm2, %xmm0

But if we can ignore NANs, the single min/max instruction is enough because there is no need to fix up the x86 logic that corresponds to something like X>Y ? X : Y.
We probably want to make other adjustments for FP intrinsics with FMF to account for specialized codegen (for example, FSQRT).

Diff Detail

Event Timeline

spatel created this revision.Nov 30 2020, 11:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 30 2020, 11:19 AM
spatel requested review of this revision.Nov 30 2020, 11:19 AM
pengfei accepted this revision.Nov 30 2020, 9:51 PM

LGTM.

llvm/test/Analysis/CostModel/X86/fmaxnum.ll
3–4

I think you can use --check-prefixes=AVX,AVX1 to reduce some duplicated checks. The same to fminnum.ll

This revision is now accepted and ready to land.Nov 30 2020, 9:51 PM
spatel marked an inline comment as done.Dec 1 2020, 7:08 AM
spatel added inline comments.
llvm/test/Analysis/CostModel/X86/fmaxnum.ll
3–4

Thanks! I'll update the RUN lines on commit.

This revision was automatically updated to reflect the committed changes.
spatel marked an inline comment as done.