This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Fix fneg lowering
ClosedPublic

Authored by tlively on Oct 5 2018, 2:40 PM.

Details

Summary

Subtraction from zero and floating point negation do not have the same
semantics, so fix lowering.

Diff Detail

Repository
rL LLVM

Event Timeline

tlively created this revision.Oct 5 2018, 2:40 PM
aheejin added inline comments.Oct 9 2018, 8:09 AM
lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
187 ↗(On Diff #168535)

Can we define ivneg or something like

// Integer vector negation
def ivneg : PatFrag<(ops node:$in), (sub immAllZeroesV, node:$in)>;

And change this pattern to resemble the simpler SIMDNegFP one, using ivneg in place of fneg, to make it simpler and symmetrical? The reason I said ivneg instead of ineg is there's already an [[ https://github.com/llvm-mirror/llvm/blob/8cc4d7e1c6c2a61e560268413a1355d0260a81b3/include/llvm/Target/TargetSelectionDAG.td#L757 | ineg ]] node there, which does not seem to support vectors.

And this is irrelevant to this CL, but there also seems to be a [[ https://github.com/llvm-mirror/llvm/blob/8cc4d7e1c6c2a61e560268413a1355d0260a81b3/include/llvm/Target/TargetSelectionDAG.td#L756 | vnot ]] node. Can we possibly use this to simplify SIMDNot pattern?

test/CodeGen/WebAssembly/simd-arith.ll
747 ↗(On Diff #168535)

To make this to work, does a floating point instruction has to have fast attribute, or only some of these fast-math flags?

tlively updated this revision to Diff 168900.Oct 9 2018, 4:20 PM
tlively marked an inline comment as done.
  • Rebase and unify FP and Int Negs
tlively updated this revision to Diff 168902.Oct 9 2018, 4:24 PM
  • change fast flag to nsz
tlively marked an inline comment as done.Oct 9 2018, 4:25 PM
tlively added inline comments.
lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
187 ↗(On Diff #168535)

Good call. vnot is on my list of things to do!

test/CodeGen/WebAssembly/simd-arith.ll
747 ↗(On Diff #168535)

Looks like only nsz was necessary.

aheejin accepted this revision.Oct 9 2018, 5:30 PM
This revision is now accepted and ready to land.Oct 9 2018, 5:30 PM
aheejin added inline comments.Oct 9 2018, 5:51 PM
test/CodeGen/WebAssembly/simd-arith.ll
747 ↗(On Diff #168535)

One-line comment on why nsz is necessary would be good

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