Changeset View
Changeset View
Standalone View
Standalone View
llvm/test/Transforms/LoopVectorize/float-minmax-instruction-flag.ll
- This file was added.
; RUN: opt < %s -loop-vectorize -force-vector-width=4 | FileCheck %s | |||||
; The function finds the smallest value from a float vector. | |||||
; Check if vectorization is enabled by instruction flag `fcmp nnan`. | |||||
;CHECK-LABEL: @minloop( | |||||
;CHECK: load <4 x float> | |||||
define float @minloop(float* nocapture readonly) { | |||||
top: | |||||
%1 = load float, float* %0 | |||||
br label %loop | |||||
loop: | |||||
%2 = phi i64 [ %8, %loop ], [ 1, %top ] | |||||
%3 = phi float [ %7, %loop ], [ %1, %top ] | |||||
%4 = getelementptr float, float* %0, i64 %2 | |||||
%5 = load float, float* %4, align 4 | |||||
%6 = fcmp nnan olt float %3, %5 | |||||
%7 = select i1 %6, float %3, float %5 | |||||
%8 = add i64 %2, 1 | |||||
%9 = icmp eq i64 %8, 65537 | |||||
br i1 %9, label %out, label %loop | |||||
out: | |||||
ret float %7 | |||||
} | |||||
; Check if vectorization is still enabled by function attribute. | |||||
;CHECK-LABEL: @minloopattr( | |||||
;CHECK: load <4 x float> | |||||
define float @minloopattr(float* nocapture readonly) #0 { | |||||
top: | |||||
%1 = load float, float* %0 | |||||
br label %loop | |||||
loop: | |||||
%2 = phi i64 [ %8, %loop ], [ 1, %top ] | |||||
%3 = phi float [ %7, %loop ], [ %1, %top ] | |||||
%4 = getelementptr float, float* %0, i64 %2 | |||||
%5 = load float, float* %4, align 4 | |||||
%6 = fcmp olt float %3, %5 | |||||
%7 = select i1 %6, float %3, float %5 | |||||
%8 = add i64 %2, 1 | |||||
%9 = icmp eq i64 %8, 65537 | |||||
br i1 %9, label %out, label %loop | |||||
out: | |||||
ret float %7 | |||||
} | |||||
attributes #0 = { "no-nans-fp-math"="true" } | |||||
; Check if vectorization is prevented without the flag or attribute. | |||||
;CHECK-LABEL: @minloopnovec( | |||||
;CHECK-NOT: load <4 x float> | |||||
define float @minloopnovec(float* nocapture readonly) { | |||||
top: | |||||
%1 = load float, float* %0 | |||||
br label %loop | |||||
loop: | |||||
%2 = phi i64 [ %8, %loop ], [ 1, %top ] | |||||
%3 = phi float [ %7, %loop ], [ %1, %top ] | |||||
%4 = getelementptr float, float* %0, i64 %2 | |||||
%5 = load float, float* %4, align 4 | |||||
%6 = fcmp olt float %3, %5 | |||||
%7 = select i1 %6, float %3, float %5 | |||||
%8 = add i64 %2, 1 | |||||
%9 = icmp eq i64 %8, 65537 | |||||
br i1 %9, label %out, label %loop | |||||
out: | |||||
ret float %7 | |||||
} |