[llvm-bugs] [Bug 51556] New: Failure to vectorize llvm.isnan calls

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Aug 20 03:13:34 PDT 2021


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

            Bug ID: 51556
           Summary: Failure to vectorize llvm.isnan calls
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: llvm-dev at redking.me.uk
                CC: a.bataev at hotmail.com, florian_hahn at apple.com,
                    llvm-bugs at lists.llvm.org, sepavloff at gmail.com,
                    spatel+llvm at rotateright.com

As well as missing Intrinsic::isnan from llvm::isTriviallyVectorizable, the SLP
call vectorization fails as we don't properly account for calls that have
different return/arg types - LV seems to have the same problem but I haven't
looked at that in detail.

opt -mtriple=x86_64-- -mcpu=btver2 -slp-vectorizer

define void @vec_isnan_f64(double* %a, double* %b, double* %c, double* %d) {
; CHECK-LABEL: @vec_isnan_f64(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[AIDX1:%.*]] = getelementptr inbounds double, double*
[[A:%.*]], i64 1
; CHECK-NEXT:    [[A0:%.*]] = load double, double* [[A]], align 8
; CHECK-NEXT:    [[A1:%.*]] = load double, double* [[AIDX1]], align 8
; CHECK-NEXT:    [[TMP0:%.*]] = bitcast double* [[B:%.*]] to <2 x double>*
; CHECK-NEXT:    [[TMP1:%.*]] = load <2 x double>, <2 x double>* [[TMP0]],
align 8
; CHECK-NEXT:    [[TMP2:%.*]] = bitcast double* [[C:%.*]] to <2 x double>*
; CHECK-NEXT:    [[TMP3:%.*]] = load <2 x double>, <2 x double>* [[TMP2]],
align 8
; CHECK-NEXT:    [[ISNAN0:%.*]] = tail call i1 @llvm.isnan.f64(double [[A0]])
; CHECK-NEXT:    [[ISNAN1:%.*]] = tail call i1 @llvm.isnan.f64(double [[A1]])
; CHECK-NEXT:    [[TMP4:%.*]] = insertelement <2 x i1> poison, i1 [[ISNAN0]],
i32 0
; CHECK-NEXT:    [[TMP5:%.*]] = insertelement <2 x i1> [[TMP4]], i1 [[ISNAN1]],
i32 1
; CHECK-NEXT:    [[TMP6:%.*]] = select <2 x i1> [[TMP5]], <2 x double>
[[TMP1]], <2 x double> [[TMP3]]
; CHECK-NEXT:    [[TMP7:%.*]] = bitcast double* [[D:%.*]] to <2 x double>*
; CHECK-NEXT:    store <2 x double> [[TMP6]], <2 x double>* [[TMP7]], align 8
; CHECK-NEXT:    ret void
;
entry:
  %aidx1 = getelementptr inbounds double, double* %a, i64 1
  %bidx1 = getelementptr inbounds double, double* %b, i64 1
  %cidx1 = getelementptr inbounds double, double* %c, i64 1
  %didx1 = getelementptr inbounds double, double* %d, i64 1
  %a0 = load double, double* %a, align 8
  %b0 = load double, double* %b, align 8
  %c0 = load double, double* %c, align 8
  %a1 = load double, double* %aidx1, align 8
  %b1 = load double, double* %bidx1, align 8
  %c1 = load double, double* %cidx1, align 8
  %isnan0 = tail call i1 @llvm.isnan.f64(double %a0)
  %isnan1 = tail call i1 @llvm.isnan.f64(double %a1)
  %r0 = select i1 %isnan0, double %b0, double %c0
  %r1 = select i1 %isnan1, double %b1, double %c1
  store double %r0, double* %d, align 8
  store double %r1, double* %didx1, align 8
  ret void
}
declare i1 @llvm.isnan.f64(double)

-- 
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/20210820/85adb5b2/attachment-0001.html>


More information about the llvm-bugs mailing list