[cfe-dev] question about fused multiply add and Clang GNU modes

Joerg Sonnenberger via cfe-dev cfe-dev at lists.llvm.org
Mon Sep 21 06:06:00 PDT 2015


On Mon, Sep 21, 2015 at 07:37:50AM -0500, Hal Finkel via cfe-dev wrote:
> We don't track the C-level expressions in the IR, but Clang will
> directly form @llvm.fmuladd intrinsics where allowed. CodeGen then
> converts these into FMA nodes, or expands them into ADD + MUL depending
> on target hooks.

Wouldn't that be suboptimal from a CSE PoV? Consider something like:

r = a + b * c + b * c * d;

If we are greedy, the b * c would end up as (a + b * c) FMA instrinsic
and the multiplication computed twice?

Joerg



More information about the cfe-dev mailing list