Skip to content

Commit 1503d18

Browse files
RKSimontru
authored andcommitted
[X86] Use correct fp immediate types in _mm_set_ss/sd
Avoids implicit sint_to_fp which wasn't occurring on strict fp codegen Fixes #104848 (cherry picked from commit 6dcce42)
1 parent b6a562d commit 1503d18

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

clang/lib/Headers/emmintrin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1771,7 +1771,7 @@ static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_undefined_pd(void) {
17711771
/// lower 64 bits contain the value of the parameter. The upper 64 bits are
17721772
/// set to zero.
17731773
static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_set_sd(double __w) {
1774-
return __extension__(__m128d){__w, 0};
1774+
return __extension__(__m128d){__w, 0.0};
17751775
}
17761776

17771777
/// Constructs a 128-bit floating-point vector of [2 x double], with each

clang/lib/Headers/xmmintrin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1910,7 +1910,7 @@ _mm_undefined_ps(void)
19101910
static __inline__ __m128 __DEFAULT_FN_ATTRS
19111911
_mm_set_ss(float __w)
19121912
{
1913-
return __extension__ (__m128){ __w, 0, 0, 0 };
1913+
return __extension__ (__m128){ __w, 0.0f, 0.0f, 0.0f };
19141914
}
19151915

19161916
/// Constructs a 128-bit floating-point vector of [4 x float], with each
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
2+
// RUN: %clang_cc1 %s -O2 -emit-llvm -o - -triple x86_64-unknown-unknown -ffreestanding -ffp-exception-behavior=maytrap -Wall -Werror | FileCheck %s
3+
4+
#include <immintrin.h>
5+
6+
// PR104848 - ensure the _mm_set_ss/d headers don't implicity promote any integer/fp values.
7+
8+
// CHECK-LABEL: @test_mm_set_ss(
9+
// CHECK-NEXT: entry:
10+
// CHECK-NEXT: [[VECINIT3_I:%.*]] = insertelement <4 x float> <float poison, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00>, float [[NUM:%.*]], i64 0
11+
// CHECK-NEXT: ret <4 x float> [[VECINIT3_I]]
12+
//
13+
__m128 test_mm_set_ss(float num)
14+
{
15+
return _mm_set_ss(num);
16+
}
17+
18+
// CHECK-LABEL: @test_mm_set_sd(
19+
// CHECK-NEXT: entry:
20+
// CHECK-NEXT: [[VECINIT1_I:%.*]] = insertelement <2 x double> <double poison, double 0.000000e+00>, double [[NUM:%.*]], i64 0
21+
// CHECK-NEXT: ret <2 x double> [[VECINIT1_I]]
22+
//
23+
__m128d test_mm_set_sd(double num)
24+
{
25+
return _mm_set_sd(num);
26+
}

0 commit comments

Comments
 (0)