diff --git a/src/SIMD.jl b/src/SIMD.jl index 22a7f61..090fd11 100644 --- a/src/SIMD.jl +++ b/src/SIMD.jl @@ -1022,6 +1022,12 @@ end @inline Base.flipsign(v1::Vec{N,T}, v2::Vec{N,T}) where {N,T<:FloatingTypes} = vifelse(signbit(v2), -v1, v1) +# Do what Base does for HWNumber: +@inline Base.literal_pow(::typeof(^), x::Vec, ::Val{0}) = one(typeof(x)) +@inline Base.literal_pow(::typeof(^), x::Vec, ::Val{1}) = x +@inline Base.literal_pow(::typeof(^), x::Vec, ::Val{2}) = x*x +@inline Base.literal_pow(::typeof(^), x::Vec, ::Val{3}) = x*x*x + for op in (:fma, :muladd) @eval begin @inline function Base.$op(v1::Vec{N,T}, diff --git a/test/runtests.jl b/test/runtests.jl index d816ebd..e379e82 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -122,6 +122,11 @@ llvm_ir(f, args) = sprint(code_llvm, f, Base.typesof(args...)) @test Tuple(op(V8I32(v8i32), -3)) === map(x->op(x,-3), v8i32) @test Tuple(op(V8I32(v8i32), V8I32(v8i32))) === map(op, v8i32, v8i32) end + + @test Tuple(V8I32(v8i32)^0) === v8i32.^0 + @test Tuple(V8I32(v8i32)^1) === v8i32.^1 + @test Tuple(V8I32(v8i32)^2) === v8i32.^2 + @test Tuple(V8I32(v8i32)^3) === v8i32.^3 end @testset "Floating point arithmetic functions" begin @@ -207,6 +212,11 @@ llvm_ir(f, args) = sprint(code_llvm, f, Base.typesof(args...)) @test Tuple(op(V4F64(v4f64), V4F64(v4f64b))) === map(op, v4f64, v4f64b) end + @test Tuple(V4F64(v4f64)^0) === v4f64.^0 + @test Tuple(V4F64(v4f64)^1) === v4f64.^1 + @test Tuple(V4F64(v4f64)^2) === v4f64.^2 + @test Tuple(V4F64(v4f64)^3) === v4f64.^3 + for op in (fma, vifelsebool, muladd) @test Tuple(op(V4F64(v4f64), V4F64(v4f64b), V4F64(v4f64c))) === map(op, v4f64, v4f64b, v4f64c)