Page MenuHomePhabricator

[SelectionDAG] Make LegalizeDAG lower FNEG using integer ops.
Needs ReviewPublic

Authored by efriedma on Tue, Jul 21, 6:22 PM.

Details

Summary

Previously, if a floating-point type was legal, but FNEG wasn't legal, we would use FSUB. Instead, we should use integer ops, to preserve the semantics. (Alternatively, there's a compiler-rt call we could use, but there isn't much reason to use that.)

It turns out we actually are still using this obscure codepath in a few cases: on some targets, we have "legal" floating-point types that don't actually support any floating-point operations. In particular, ARM and AArch64 are using this path.

The implementation is pretty simple because we can reuse the infrastructure from FCOPYSIGN.

See also 9a3dc3e, the corresponding change to type legalization.

Fixes https://bugs.llvm.org/show_bug.cgi?id=46792 .

Diff Detail

Unit TestsFailed

TimeTest
250 mslinux > LLVM.CodeGen/AArch64::Unknown Unit Message ("")
Script: -- : 'RUN: at line 1'; /mnt/disks/ssd0/agent/llvm-project/build/bin/llc -mtriple=aarch64-none-eabi /mnt/disks/ssd0/agent/llvm-project/llvm/test/CodeGen/AArch64/fp-intrinsics.ll -o - | /mnt/disks/ssd0/agent/llvm-project/build/bin/FileCheck /mnt/disks/ssd0/agent/llvm-project/llvm/test/CodeGen/AArch64/fp-intrinsics.ll
640 mslinux > LLVM.CodeGen/ARM::Unknown Unit Message ("")
Script: -- : 'RUN: at line 1'; /mnt/disks/ssd0/agent/llvm-project/build/bin/llc -mtriple=armv8a-none-eabi /mnt/disks/ssd0/agent/llvm-project/llvm/test/CodeGen/ARM/fp-intrinsics.ll -o - | /mnt/disks/ssd0/agent/llvm-project/build/bin/FileCheck /mnt/disks/ssd0/agent/llvm-project/llvm/test/CodeGen/ARM/fp-intrinsics.ll --check-prefixes=CHECK,CHECK-SP,CHECK-DP,CHECK-SP-V8,CHECK-DP-V8
80 mswindows > Clang.CoverageMapping::Unknown Unit Message ("")
Script: -- : 'RUN: at line 1'; sed 's/[ ]*\/\/.*//' C:\ws\w64\llvm-project\premerge-checks\clang\test\CoverageMapping\includehell.cpp > C:\ws\w64\llvm-project\premerge-checks\build\tools\clang\test\CoverageMapping\Output\includehell.cpp.tmp.stripped.cpp
310 mswindows > LLVM.CodeGen/AArch64::Unknown Unit Message ("")
Script: -- : 'RUN: at line 1'; c:\ws\w64\llvm-project\premerge-checks\build\bin\llc.exe -mtriple=aarch64-none-eabi C:\ws\w64\llvm-project\premerge-checks\llvm\test\CodeGen\AArch64\fp-intrinsics.ll -o - | c:\ws\w64\llvm-project\premerge-checks\build\bin\filecheck.exe C:\ws\w64\llvm-project\premerge-checks\llvm\test\CodeGen\AArch64\fp-intrinsics.ll
3,470 mswindows > LLVM.CodeGen/ARM::Unknown Unit Message ("")
Script: -- : 'RUN: at line 1'; c:\ws\w64\llvm-project\premerge-checks\build\bin\llc.exe -mtriple=armv8a-none-eabi C:\ws\w64\llvm-project\premerge-checks\llvm\test\CodeGen\ARM\fp-intrinsics.ll -o - | c:\ws\w64\llvm-project\premerge-checks\build\bin\filecheck.exe C:\ws\w64\llvm-project\premerge-checks\llvm\test\CodeGen\ARM\fp-intrinsics.ll --check-prefixes=CHECK,CHECK-SP,CHECK-DP,CHECK-SP-V8,CHECK-DP-V8

Event Timeline

efriedma created this revision.Tue, Jul 21, 6:22 PM
Herald added a project: Restricted Project. · View Herald TranscriptTue, Jul 21, 6:22 PM

GlobalISel has the same problem

RKSimon added inline comments.Sun, Jul 26, 5:46 AM
llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
3238

Is it worth moving this to a ExpandFNEG helper like the other ops?