HomePhabricator

[DAGCombine] reassoc flag shouldn't enable contract

Authored by jsji on Jun 21 2021, 12:25 PM.

Description

[DAGCombine] reassoc flag shouldn't enable contract

According to IR LangRef, the FMF flag:

contract
Allow floating-point contraction (e.g. fusing a multiply followed by an
addition into a fused multiply-and-add).

reassoc
Allow reassociation transformations for floating-point instructions.
This may dramatically change results in floating-point.

My understanding is that these two flags shouldn't imply each other,
as we might have a SDNode that can be reassociated with others, but
not contractble.

eg: We may want following fmul/fad/fsub to freely reassoc, but don't
want fma being generated here.

%F = fmul reassoc double %A, %B         ; <double> [#uses=1]
%G = fmul reassoc double %C, %D         ; <double> [#uses=1]
%H = fadd reassoc double %F, %G         ; <double> [#uses=1]
%I = fsub reassoc double %H, %E         ; <double> [#uses=1]

Before https://reviews.llvm.org/D45710, reassoc flag actually
did not imply isContratable either.

The current implementation also only check the flag in fadd node,
ignoring fmul node, this patch update that as well.

Reviewed By: spatel, qiucf

Differential Revision: https://reviews.llvm.org/D104247

Details

Committed
jsjiJun 21 2021, 2:15 PM
Reviewer
spatel
Differential Revision
D104247: [DAGCombine] reassoc flag shouldn't enable contract
Parents
rG2bfe0536e514: [UpdateCCTestChecks] Fix --replace-value-regex across RUN lines
Branches
Unknown
Tags
Unknown