|
| 1 | +;=========================== begin_copyright_notice ============================ |
| 2 | +; |
| 3 | +; Copyright (C) 2024 Intel Corporation |
| 4 | +; |
| 5 | +; SPDX-License-Identifier: MIT |
| 6 | +; |
| 7 | +;============================ end_copyright_notice ============================= |
| 8 | + |
| 9 | +; RUN: %opt %use_old_pass_manager% -GenXLowering -march=genx64 -mcpu=XeHPC -mtriple=spir64-unknown-unknown -S < %s | FileCheck %s |
| 10 | + |
| 11 | +declare <4 x half> @llvm.copysign.v4f16(<4 x half>, <4 x half>) |
| 12 | +declare <4 x bfloat> @llvm.copysign.v4bf16(<4 x bfloat>, <4 x bfloat>) |
| 13 | +declare <4 x float> @llvm.copysign.v4f32(<4 x float>, <4 x float>) |
| 14 | +declare <4 x double> @llvm.copysign.v4f64(<4 x double>, <4 x double>) |
| 15 | + |
| 16 | +; CHECK-LABEL: @test_v4f16 |
| 17 | +define <4 x half> @test_v4f16(<4 x half> %src, <4 x half> %sign) { |
| 18 | +; CHECK: [[MAG:%.*]] = bitcast <4 x half> %src to <4 x i16> |
| 19 | +; CHECK: [[SGN:%.*]] = bitcast <4 x half> %sign to <4 x i16> |
| 20 | +; CHECK: [[ABS:%.*]] = and <4 x i16> [[MAG]], <i16 32767, i16 32767, i16 32767, i16 32767> |
| 21 | +; CHECK: [[SIGN:%.*]] = and <4 x i16> [[SGN]], <i16 -32768, i16 -32768, i16 -32768, i16 -32768> |
| 22 | +; CHECK: [[RES:%.*]] = or <4 x i16> [[ABS]], [[SIGN]] |
| 23 | +; CHECK: [[RES_HALF:%.*]] = bitcast <4 x i16> [[RES]] to <4 x half> |
| 24 | +; CHECK: ret <4 x half> [[RES_HALF]] |
| 25 | + %res = call <4 x half> @llvm.copysign.v4f16(<4 x half> %src, <4 x half> %sign) |
| 26 | + ret <4 x half> %res |
| 27 | +} |
| 28 | + |
| 29 | +; CHECK-LABEL: @test_v4bf16 |
| 30 | +define <4 x bfloat> @test_v4bf16(<4 x bfloat> %src, <4 x bfloat> %sign) { |
| 31 | +; CHECK: [[MAG:%.*]] = bitcast <4 x bfloat> %src to <4 x i16> |
| 32 | +; CHECK: [[SGN:%.*]] = bitcast <4 x bfloat> %sign to <4 x i16> |
| 33 | +; CHECK: [[ABS:%.*]] = and <4 x i16> [[MAG]], <i16 32767, i16 32767, i16 32767, i16 32767> |
| 34 | +; CHECK: [[SIGN:%.*]] = and <4 x i16> [[SGN]], <i16 -32768, i16 -32768, i16 -32768, i16 -32768> |
| 35 | +; CHECK: [[RES:%.*]] = or <4 x i16> [[ABS]], [[SIGN]] |
| 36 | +; CHECK: [[RES_BF:%.*]] = bitcast <4 x i16> [[RES]] to <4 x bfloat> |
| 37 | +; CHECK: ret <4 x bfloat> [[RES_BF]] |
| 38 | + %res = call <4 x bfloat> @llvm.copysign.v4bf16(<4 x bfloat> %src, <4 x bfloat> %sign) |
| 39 | + ret <4 x bfloat> %res |
| 40 | +} |
| 41 | + |
| 42 | +; CHECK-LABEL: @test_v4f32 |
| 43 | +define <4 x float> @test_v4f32(<4 x float> %src, <4 x float> %sign) { |
| 44 | +; CHECK: [[MAG:%.*]] = bitcast <4 x float> %src to <8 x i16> |
| 45 | +; CHECK: [[SGN:%.*]] = bitcast <4 x float> %sign to <8 x i16> |
| 46 | +; CHECK: [[MAG_EXTRACT:%.*]] = call <4 x i16> @llvm.genx.rdregioni.v4i16.v8i16.i16(<8 x i16> [[MAG]], i32 2, i32 1, i32 0, i16 2, i32 undef) |
| 47 | +; CHECK: [[SGN_EXTRACT:%.*]] = call <4 x i16> @llvm.genx.rdregioni.v4i16.v8i16.i16(<8 x i16> [[SGN]], i32 2, i32 1, i32 0, i16 2, i32 undef) |
| 48 | +; CHECK: [[ABS:%.*]] = and <4 x i16> [[MAG_EXTRACT]], <i16 32767, i16 32767, i16 32767, i16 32767> |
| 49 | +; CHECK: [[SIGN:%.*]] = and <4 x i16> [[SGN_EXTRACT]], <i16 -32768, i16 -32768, i16 -32768, i16 -32768> |
| 50 | +; CHECK: [[RES:%.*]] = or <4 x i16> [[ABS]], [[SIGN]] |
| 51 | +; CHECK: [[RES_INSERT:%.*]] = call <8 x i16> @llvm.genx.wrregioni.v8i16.v4i16.i16.i1(<8 x i16> [[MAG]], <4 x i16> [[RES]], i32 2, i32 1, i32 0, i16 2, i32 undef, i1 true) |
| 52 | +; CHECK: [[RES_FLOAT:%.*]] = bitcast <8 x i16> [[RES_INSERT]] to <4 x float> |
| 53 | +; CHECK: ret <4 x float> [[RES_FLOAT]] |
| 54 | + %res = call <4 x float> @llvm.copysign.v4f32(<4 x float> %src, <4 x float> %sign) |
| 55 | + ret <4 x float> %res |
| 56 | +} |
| 57 | + |
| 58 | +; CHECK-LABEL: @test_v4f64 |
| 59 | +define <4 x double> @test_v4f64(<4 x double> %src, <4 x double> %sign) { |
| 60 | +; CHECK: [[MAG:%.*]] = bitcast <4 x double> %src to <16 x i16> |
| 61 | +; CHECK: [[SGN:%.*]] = bitcast <4 x double> %sign to <16 x i16> |
| 62 | +; CHECK: [[MAG_EXTRACT:%.*]] = call <4 x i16> @llvm.genx.rdregioni.v4i16.v16i16.i16(<16 x i16> [[MAG]], i32 4, i32 1, i32 0, i16 6, i32 undef) |
| 63 | +; CHECK: [[SGN_EXTRACT:%.*]] = call <4 x i16> @llvm.genx.rdregioni.v4i16.v16i16.i16(<16 x i16> [[SGN]], i32 4, i32 1, i32 0, i16 6, i32 undef) |
| 64 | +; CHECK: [[ABS:%.*]] = and <4 x i16> [[MAG_EXTRACT]], <i16 32767, i16 32767, i16 32767, i16 32767> |
| 65 | +; CHECK: [[SIGN:%.*]] = and <4 x i16> [[SGN_EXTRACT]], <i16 -32768, i16 -32768, i16 -32768, i16 -32768> |
| 66 | +; CHECK: [[RES:%.*]] = or <4 x i16> [[ABS]], [[SIGN]] |
| 67 | +; CHECK: [[RES_INSERT:%.*]] = call <16 x i16> @llvm.genx.wrregioni.v16i16.v4i16.i16.i1(<16 x i16> [[MAG]], <4 x i16> [[RES]], i32 4, i32 1, i32 0, i16 6, i32 undef, i1 true) |
| 68 | +; CHECK: [[RES_DOUBLE:%.*]] = bitcast <16 x i16> [[RES_INSERT]] to <4 x double> |
| 69 | +; CHECK: ret <4 x double> [[RES_DOUBLE]] |
| 70 | + %res = call <4 x double> @llvm.copysign.v4f64(<4 x double> %src, <4 x double> %sign) |
| 71 | + ret <4 x double> %res |
| 72 | +} |
0 commit comments