| ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals none --filter "(:|reduce\.fadd)" --version 6 | |
| ; Two targets exercise the two halves of the fp_unsafe hint. | |
| ; | |
| ; ARMv7 NEON is neither AArch64 nor MVE, so its vector FP units flush | |
| ; subnormals to zero and TTI::isFPVectorizationPotentiallyUnsafe() is true | |
| ; there. The hint controls the resulting isPotentiallyUnsafe() guard. | |
| ; | |
| ; Armv8.1-M MVE has IEEE-754 compliant vector FP, so that guard is inactive | |
| ; and the hint only affects FP reordering. | |
| ; RUN: opt -passes='loop-vectorize' -mtriple=armv7-none-linux-gnueabihf -mattr=+neon \ | |
| ; RUN: -force-vector-width=4 -S < %s | FileCheck %s --check-prefix=NEON | |
| ; RUN: opt -passes='loop-vectorize' -mtriple=thumbv8.1m.main-none-eabi -mattr=+mve.fp \ | |
| ; RUN: -force-vector-width=4 -S < %s | FileCheck %s --check-prefix=MVE | |
| ; No hint: the guard rejects the loop on NEON; on MVE it is inactive, so the | |
| ; loop vectorizes with a reordered reduction. | |
| ; UTC_ARGS: --disable | |
| define float @no_hint(ptr %A, i64 %n) { | |
| ; NEON-LABEL: define float @no_hint( | |
| ; NEON-SAME: ptr [[A:%.*]], i64 [[N:%.*]]) #[[ATTR0:[0-9]+]] { | |
| ; NEON: [[ENTRY:.*:]] | |
| ; NEON: [[LOOP:.*:]] | |
| ; NEON: [[EXIT:.*:]] | |
| ; NEON-NOT: vector.body | |
| ; | |
| ; MVE-LABEL: define float @no_hint( | |
| ; MVE-SAME: ptr [[A:%.*]], i64 [[N:%.*]]) #[[ATTR0:[0-9]+]] { | |
| ; MVE: [[ENTRY:.*:]] | |
| ; MVE: [[VECTOR_PH:.*:]] | |
| ; MVE: [[VECTOR_BODY:.*:]] | |
| ; MVE: [[MIDDLE_BLOCK:.*:]] | |
| ; MVE: [[TMP4:%.*]] = call float @llvm.vector.reduce.fadd.v4f32(float -0.000000e+00, <4 x float> [[TMP2:%.*]]) | |
| ; MVE: [[SCALAR_PH:.*:]] | |
| ; MVE: [[LOOP:.*:]] | |
| ; MVE: [[EXIT:.*:]] | |
| ; | |
| entry: | |
| br label %loop | |
| loop: | |
| %i = phi i64 [ 0, %entry ], [ %i.next, %loop ] | |
| %sum = phi float [ 0.0, %entry ], [ %sum.next, %loop ] | |
| %ptr = getelementptr inbounds float, ptr %A, i64 %i | |
| %val = load float, ptr %ptr, align 4 | |
| %sum.next = fadd float %sum, %val | |
| %i.next = add nuw nsw i64 %i, 1 | |
| %cond = icmp eq i64 %i.next, %n | |
| br i1 %cond, label %exit, label %loop | |
| exit: | |
| ret float %sum.next | |
| } | |
| ; UTC_ARGS: --enable | |
| ; fp_unsafe.enable: suppresses the guard, so the loop vectorizes on both | |
| ; targets. | |
| define float @fp_unsafe_enable(ptr %A, i64 %n) { | |
| ; NEON-LABEL: define float @fp_unsafe_enable( | |
| ; NEON-SAME: ptr [[A:%.*]], i64 [[N:%.*]]) #[[ATTR0:[0-9]+]] { | |
| ; NEON: [[ENTRY:.*:]] | |
| ; NEON: [[VECTOR_PH:.*:]] | |
| ; NEON: [[VECTOR_BODY:.*:]] | |
| ; NEON: [[MIDDLE_BLOCK:.*:]] | |
| ; NEON: [[TMP4:%.*]] = call float @llvm.vector.reduce.fadd.v4f32(float -0.000000e+00, <4 x float> [[TMP2:%.*]]) | |
| ; NEON: [[SCALAR_PH:.*:]] | |
| ; NEON: [[LOOP:.*:]] | |
| ; NEON: [[EXIT:.*:]] | |
| ; | |
| ; MVE-LABEL: define float @fp_unsafe_enable( | |
| ; MVE-SAME: ptr [[A:%.*]], i64 [[N:%.*]]) #[[ATTR0:[0-9]+]] { | |
| ; MVE: [[ENTRY:.*:]] | |
| ; MVE: [[VECTOR_PH:.*:]] | |
| ; MVE: [[VECTOR_BODY:.*:]] | |
| ; MVE: [[MIDDLE_BLOCK:.*:]] | |
| ; MVE: [[TMP4:%.*]] = call float @llvm.vector.reduce.fadd.v4f32(float -0.000000e+00, <4 x float> [[TMP2:%.*]]) | |
| ; MVE: [[SCALAR_PH:.*:]] | |
| ; MVE: [[LOOP:.*:]] | |
| ; MVE: [[EXIT:.*:]] | |
| ; | |
| entry: | |
| br label %loop | |
| loop: | |
| %i = phi i64 [ 0, %entry ], [ %i.next, %loop ] | |
| %sum = phi float [ 0.0, %entry ], [ %sum.next, %loop ] | |
| %ptr = getelementptr inbounds float, ptr %A, i64 %i | |
| %val = load float, ptr %ptr, align 4 | |
| %sum.next = fadd float %sum, %val | |
| %i.next = add nuw nsw i64 %i, 1 | |
| %cond = icmp eq i64 %i.next, %n | |
| br i1 %cond, label %exit, label %loop, !llvm.loop !0 | |
| exit: | |
| ret float %sum.next | |
| } | |
| ; fp_unsafe.disable: rejected on both targets, but for different reasons. On | |
| ; NEON the guard rejects it (UnsafeFP); on MVE the guard is inactive and the | |
| ; rejection comes from suppressed FP reordering (CantReorderFPOps). | |
| ; UTC_ARGS: --disable | |
| define float @fp_unsafe_disable(ptr %A, i64 %n) { | |
| ; NEON-LABEL: define float @fp_unsafe_disable( | |
| ; NEON-SAME: ptr [[A:%.*]], i64 [[N:%.*]]) #[[ATTR0]] { | |
| ; NEON: [[ENTRY:.*:]] | |
| ; NEON: [[LOOP:.*:]] | |
| ; NEON: [[EXIT:.*:]] | |
| ; NEON-NOT: vector.body | |
| ; | |
| ; MVE-LABEL: define float @fp_unsafe_disable( | |
| ; MVE-SAME: ptr [[A:%.*]], i64 [[N:%.*]]) #[[ATTR0]] { | |
| ; MVE: [[ENTRY:.*:]] | |
| ; MVE: [[LOOP:.*:]] | |
| ; MVE: [[EXIT:.*:]] | |
| ; MVE-NOT: vector.body | |
| ; | |
| entry: | |
| br label %loop | |
| loop: | |
| %i = phi i64 [ 0, %entry ], [ %i.next, %loop ] | |
| %sum = phi float [ 0.0, %entry ], [ %sum.next, %loop ] | |
| %ptr = getelementptr inbounds float, ptr %A, i64 %i | |
| %val = load float, ptr %ptr, align 4 | |
| %sum.next = fadd float %sum, %val | |
| %i.next = add nuw nsw i64 %i, 1 | |
| %cond = icmp eq i64 %i.next, %n | |
| br i1 %cond, label %exit, label %loop, !llvm.loop !2 | |
| exit: | |
| ret float %sum.next | |
| } | |
| !0 = distinct !{!0, !1} | |
| !1 = !{!"llvm.loop.vectorize.fp_unsafe.enable"} | |
| !2 = distinct !{!2, !3} | |
| !3 = !{!"llvm.loop.vectorize.fp_unsafe.disable"} |