<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Induction on fmuladd cannot be vectorized"
   href="https://bugs.llvm.org/show_bug.cgi?id=33338">33338</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Induction on fmuladd cannot be vectorized
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>4.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Loop Optimizer
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>yyc1992@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>IIUC it should always be valid (though not necessarily performable) to replace
`llvm.fmuladd` with `fmul` and `fadd` so it is a little surprising to see that
`llvm.fmuladd` can cause worse vectorization when it's used on induction
variable.

Running through `opt -O2` the following code does not vectorize but it
vectorizes if the `fmuladd` is replaced with `fmul` and `fadd` as shown in the
commented out code.

```
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: nounwind readonly uwtable
define double @f(double* nocapture readonly, double* nocapture readonly, i32)
local_unnamed_addr #0 {
  %4 = icmp sgt i32 %2, 0
  br i1 %4, label %5, label %8

; <label>:5:                                      ; preds = %3
  %6 = zext i32 %2 to i64
  br label %10

; <label>:7:                                      ; preds = %10
  br label %8

; <label>:8:                                      ; preds = %7, %3
  %9 = phi double [ 0.000000e+00, %3 ], [ %17, %7 ]
  ret double %9

; <label>:10:                                     ; preds = %5, %10
  %11 = phi i64 [ %18, %10 ], [ 0, %5 ]
  %12 = phi double [ %17, %10 ], [ 0.000000e+00, %5 ]
  %13 = getelementptr inbounds double, double* %0, i64 %11
  %14 = load double, double* %13, align 8
  %15 = getelementptr inbounds double, double* %1, i64 %11
  %16 = load double, double* %15, align 8
  %17 = tail call fast double @llvm.fmuladd.f64(double %14, double %16, double
%12)
  ; %r = fmul fast double %14, %16
  ; %17 = fadd fast double %r, %12
  %18 = add nuw nsw i64 %11, 1
  %19 = icmp eq i64 %18, %6
  br i1 %19, label %7, label %10
}

; Function Attrs: nounwind readnone
declare double @llvm.fmuladd.f64(double, double, double) #1

attributes #0 = { nounwind readonly uwtable "target-features"="+fma" }
attributes #1 = { nounwind readnone }
```</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>