[llvm-bugs] [Bug 35538] New: [LoopVectorize] fast-math-flags on fcmp are not propagated correctly

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Dec 5 12:21:35 PST 2017


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

            Bug ID: 35538
           Summary: [LoopVectorize] fast-math-flags on fcmp are not
                    propagated correctly
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Loop Optimizer
          Assignee: unassignedbugs at nondot.org
          Reporter: spatel+llvm at rotateright.com
                CC: llvm-bugs at lists.llvm.org

This is the IR for the max loop in bug 35284 when compiled with
-ffinite-math-only:

target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.13.0"

define float @test(float* nocapture readonly %a, i32 %N) #0 {
entry:
  %cmp12 = icmp sgt i32 %N, 0
  br i1 %cmp12, label %for.body.lr.ph, label %for.cond.cleanup

for.body.lr.ph:                       
  %wide.trip.count = zext i32 %N to i64
  br label %for.body

for.cond.cleanup:                         
  %max.0.lcssa = phi float [ -1.000000e+00, %entry ], [ %max.0., %for.body ]
  ret float %max.0.lcssa

for.body:    
  %indvars.iv = phi i64 [ 0, %for.body.lr.ph ], [ %indvars.iv.next, %for.body ]
  %max.013 = phi float [ -1.000000e+00, %for.body.lr.ph ], [ %max.0., %for.body
]
  %arrayidx = getelementptr inbounds float, float* %a, i64 %indvars.iv
  %0 = load float, float* %arrayidx, align 4, !tbaa !3
  %cmp1.inv = fcmp nnan ninf oge float %0, %max.013
  %max.0. = select i1 %cmp1.inv, float %0, float %max.013
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond, label %for.cond.cleanup, label %for.body
}

attributes #0 = { norecurse nounwind readonly ssp uwtable
"correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false"
"less-precise-fpmad"="false" "no-frame-pointer-elim"="true"
"no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="true"
"no-jump-tables"="false" "no-nans-fp-math"="true"
"no-signed-zeros-fp-math"="false" "no-trapping-math"="false"
"stack-protector-buffer-size"="8" "target-cpu"="penryn"
"target-features"="+cx16,+fxsr,+mmx,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87"
"unsafe-fp-math"="false" "use-soft-float"="false" }

!llvm.module.flags = !{!0, !1}
!llvm.ident = !{!2}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"PIC Level", i32 2}
!2 = !{!"clang version 6.0.0 (trunk 319684)"}
!3 = !{!4, !4, i64 0}
!4 = !{!"float", !5, i64 0}
!5 = !{!"omnipotent char", !6, i64 0}
!6 = !{!"Simple C/C++ TBAA"}

-------------------------------------------------------------------------------

$ ./opt -loop-vectorize 35284finite.ll -S | grep fast
  %rdx.minmax.cmp = fcmp fast ogt <4 x float> %11, %12
  %rdx.minmax.cmp4 = fcmp fast ogt <4 x float> %rdx.minmax.select, %rdx.shuf
  %rdx.minmax.cmp7 = fcmp fast ogt <4 x float> %rdx.minmax.select5, %rdx.shuf6


The vectorizer took one fcmp with only 'nnan ninf', and it got replicated to
'fast' sometimes...but not all the time:

$ ./opt -loop-vectorize 35284finite.ll -S | grep nnan
  %8 = fcmp nnan ninf oge <4 x float> %wide.load, %vec.phi
  %9 = fcmp nnan ninf oge <4 x float> %wide.load3, %vec.phi2
  %cmp1.inv = fcmp nnan ninf oge float %15, %max.013

-- 
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/20171205/8728aec3/attachment.html>


More information about the llvm-bugs mailing list