[PATCH] D47335: [InstCombine] Enable more reassociations using FMF 'reassoc' + 'nsz'

Warren Ristow via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 24 10:19:12 PDT 2018


wristow created this revision.
wristow added reviewers: spatel, mcberg2017.

Reassociation of math ops in some contexts (especially vector contexts)
has generally only been happening when the 'fast' FMF was set.  This
enables reassoication when only the finer grained controls 'reassoc' and
'nsz' are set.

This also improves many vector reassociation opportunities.  It also improves some scalar reassociation, although I haven't looked for tests that can be made more aggressive on the scalar side yet (or written new tests on the scalar side).

This changes `Instruction::isAssociative()` to use `hasAllowReassoc() && hasNoSignedZeros()` rather than `isFast()` for `FMul` and `FAdd` ops.  I believe that ultimately `Instruction::isAssociative()` should only check `hasAllowReassoc()` for these ops, and that transformations that also require `nsz` should be handled by the callers, as appropriate.  Auditing all the callers would be needed to get that correct.  I think this improves the situation, without creating a danger.


https://reviews.llvm.org/D47335

Files:
  lib/IR/Instruction.cpp
  test/Transforms/InstCombine/2006-10-26-VectorReassoc.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47335.148438.patch
Type: text/x-patch
Size: 10307 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180524/3eb3ab2e/attachment.bin>


More information about the llvm-commits mailing list