From 9b44239f030a0268413c7e267f8b9d7ca948dfb2 Mon Sep 17 00:00:00 2001 From: Lilith Orion Hafner Date: Tue, 23 Apr 2024 16:50:02 -0500 Subject: [PATCH] Remove some UB from examples in performance tips (#54221) Remove some UB from examples in performance tips Fixes #54218 I also changed the iteration specification to better align with elsewhere in the document. A separate PR may want to delete or revise this section if automatic simd has improved. Nevertheless, I think this PR should be unobjectionable as is. --- doc/src/manual/performance-tips.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/src/manual/performance-tips.md b/doc/src/manual/performance-tips.md index be6bc1087b6e3..6092d48902d19 100644 --- a/doc/src/manual/performance-tips.md +++ b/doc/src/manual/performance-tips.md @@ -1446,7 +1446,7 @@ the optimizer from trying to be too clever and defeat our benchmark): ```julia @noinline function inner(x, y) s = zero(eltype(x)) - for i=eachindex(x) + for i in eachindex(x, y) @inbounds s += x[i]*y[i] end return s @@ -1454,7 +1454,7 @@ end @noinline function innersimd(x, y) s = zero(eltype(x)) - @simd for i = eachindex(x) + @simd for i in eachindex(x, y) @inbounds s += x[i] * y[i] end return s