Skip to content

Commit bae1662

Browse files
committed
address pr feedback
1 parent d72983f commit bae1662

File tree

5 files changed

+11
-12
lines changed

5 files changed

+11
-12
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

+1-1
Original file line numberDiff line numberDiff line change
@@ -12356,7 +12356,7 @@ def err_builtin_invalid_arg_type: Error <
1235612356
"an unsigned integer|"
1235712357
"an 'int'|"
1235812358
"a vector of floating points|"
12359-
"a vector of integers or floating points}1 (was %2)">;
12359+
"a vector of arithmetic element type}1 (was %2)">;
1236012360

1236112361
def err_builtin_matrix_disabled: Error<
1236212362
"matrix types extension is disabled. Pass -fenable-matrix to enable it">;

clang/lib/AST/ByteCode/InterpBuiltin.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
//===----------------------------------------------------------------------===//
88
#include "../ExprConstShared.h"
99
#include "Boolean.h"
10-
#include "ByteCode/Floating.h"
1110
#include "Compiler.h"
1211
#include "EvalEmitter.h"
1312
#include "Interp.h"

clang/lib/CodeGen/CGBuiltin.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -4283,7 +4283,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
42834283
if (E->getArg(0)->getType()->hasFloatingRepresentation()) {
42844284
Value *X = EmitScalarExpr(E->getArg(0));
42854285
auto EltTy = X->getType()->getScalarType();
4286-
Value *Seed = ConstantFP::get(EltTy, 0);
4286+
Value *Seed = ConstantFP::get(EltTy, -0.0);
42874287
return RValue::get(Builder.CreateIntrinsic(
42884288
/*ReturnType=*/EltTy, llvm::Intrinsic::vector_reduce_fadd,
42894289
ArrayRef<Value *>{Seed, X}, nullptr, "rdx.fadd"));
@@ -4296,7 +4296,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
42964296
if (E->getArg(0)->getType()->hasFloatingRepresentation()) {
42974297
Value *X = EmitScalarExpr(E->getArg(0));
42984298
auto EltTy = X->getType()->getScalarType();
4299-
Value *Seed = ConstantFP::get(EltTy, 0);
4299+
Value *Seed = ConstantFP::get(EltTy, 1.0);
43004300
return RValue::get(Builder.CreateIntrinsic(
43014301
/*ReturnType=*/EltTy, llvm::Intrinsic::vector_reduce_fmul,
43024302
ArrayRef<Value *>{Seed, X}, nullptr, "rdx.fmul"));

clang/test/CodeGen/builtins-reduction-math.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ void test_builtin_reduce_min(float4 vf1, si8 vi1, u4 vu1) {
6464

6565
void test_builtin_reduce_addf(float4 vf4, double4 vd4) {
6666
// CHECK: [[VF4:%.+]] = load <4 x float>, ptr %vf4.addr, align 16
67-
// CHECK-NEXT: call float @llvm.vector.reduce.fadd.v4f32(float 0.000000e+00, <4 x float> [[VF4]])
67+
// CHECK-NEXT: call float @llvm.vector.reduce.fadd.v4f32(float -0.000000e+00, <4 x float> [[VF4]])
6868
float r2 = __builtin_reduce_add(vf4);
6969

7070
// CHECK: [[VD4:%.+]] = load <4 x double>, ptr %vd4.addr, align 16
71-
// CHECK-NEXT: call double @llvm.vector.reduce.fadd.v4f64(double 0.000000e+00, <4 x double> [[VD4]])
71+
// CHECK-NEXT: call double @llvm.vector.reduce.fadd.v4f64(double -0.000000e+00, <4 x double> [[VD4]])
7272
double r3 = __builtin_reduce_add(vd4);
7373
}
7474

@@ -96,11 +96,11 @@ void test_builtin_reduce_add(si8 vi1, u4 vu1) {
9696

9797
void test_builtin_reduce_mulf(float4 vf4, double4 vd4) {
9898
// CHECK: [[VF4:%.+]] = load <4 x float>, ptr %vf4.addr, align 16
99-
// CHECK-NEXT: call float @llvm.vector.reduce.fmul.v4f32(float 0.000000e+00, <4 x float> [[VF4]])
99+
// CHECK-NEXT: call float @llvm.vector.reduce.fmul.v4f32(float 1.000000e+00, <4 x float> [[VF4]])
100100
float r2 = __builtin_reduce_mul(vf4);
101101

102102
// CHECK: [[VD4:%.+]] = load <4 x double>, ptr %vd4.addr, align 16
103-
// CHECK-NEXT: call double @llvm.vector.reduce.fmul.v4f64(double 0.000000e+00, <4 x double> [[VD4]])
103+
// CHECK-NEXT: call double @llvm.vector.reduce.fmul.v4f64(double 1.000000e+00, <4 x double> [[VD4]])
104104
double r3 = __builtin_reduce_mul(vd4);
105105
}
106106

clang/test/Sema/builtins-reduction-math.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ void test_builtin_reduce_add(int i, float f, int3 iv) {
4747
// expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
4848

4949
i = __builtin_reduce_add(i);
50-
// expected-error@-1 {{1st argument must be a vector of integers or floating points (was 'int')}}
50+
// expected-error@-1 {{1st argument must be a vector of arithmetic element type (was 'int')}}
5151

5252
f = __builtin_reduce_add(f);
53-
// expected-error@-1 {{1st argument must be a vector of integers or floating points (was 'float')}}
53+
// expected-error@-1 {{1st argument must be a vector of arithmetic element type (was 'float')}}
5454
}
5555

5656
void test_builtin_reduce_mul(int i, float f, int3 iv) {
@@ -64,10 +64,10 @@ void test_builtin_reduce_mul(int i, float f, int3 iv) {
6464
// expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
6565

6666
i = __builtin_reduce_mul(i);
67-
// expected-error@-1 {{1st argument must be a vector of integers or floating points (was 'int')}}
67+
// expected-error@-1 {{1st argument must be a vector of arithmetic element type (was 'int')}}
6868

6969
f = __builtin_reduce_mul(f);
70-
// expected-error@-1 {{1st argument must be a vector of integers or floating points (was 'float')}}
70+
// expected-error@-1 {{1st argument must be a vector of arithmetic element type (was 'float')}}
7171
}
7272

7373
void test_builtin_reduce_xor(int i, float4 v, int3 iv) {

0 commit comments

Comments
 (0)