[llvm-bugs] [Bug 33338] New: Induction on fmuladd cannot be vectorized

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jun 6 20:11:52 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=33338

            Bug ID: 33338
           Summary: Induction on fmuladd cannot be vectorized
           Product: libraries
           Version: 4.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Loop Optimizer
          Assignee: unassignedbugs at nondot.org
          Reporter: yyc1992 at gmail.com
                CC: llvm-bugs at lists.llvm.org

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 }
```

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170607/609e4cc9/attachment-0001.html>


More information about the llvm-bugs mailing list