[PATCH] D111985: [Clang] Add elementwise min/max builtins.

2021-10-26 Thread Florian Hahn via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. fhahn marked 3 inline comments as done. Closed by commit rG1ef25d28c19e: [Clang] Add elementwise min/max builtins. (authored by fhahn). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION

[PATCH] D111985: [Clang] Add elementwise min/max builtins.

2021-10-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. LGTM, thank you! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111985/new/ https://reviews.llvm.org/D111985

[PATCH] D111985: [Clang] Add elementwise min/max builtins.

2021-10-26 Thread Florian Hahn via Phabricator via cfe-commits
fhahn marked 3 inline comments as done. fhahn added inline comments. Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:8747-8748 +def err_elementwise_math_arg_types_mismatch : Error < + "argument types do not match, %0 != %1">; + aaron.ballman

[PATCH] D111985: [Clang] Add elementwise min/max builtins.

2021-10-26 Thread Florian Hahn via Phabricator via cfe-commits
fhahn updated this revision to Diff 382300. fhahn marked 3 inline comments as done. fhahn added a comment. Address latest comments, thanks - Added a generic `err_builtin_invalid_arg_type` diagnostic kind, which can also be used for some of the matrix type mismatches (see D112532

[PATCH] D111985: [Clang] Add elementwise min/max builtins.

2021-10-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. I thought of another test case -- should these new functions work on complex types? (Those are weird enough we may want to consider adding both Sema and CodeGen tests if we do support them, and Sema tests alone if we don't.) Repository: rG LLVM Github Monorepo

[PATCH] D111985: [Clang] Add elementwise min/max builtins.

2021-10-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:8747-8748 +def err_elementwise_math_arg_types_mismatch : Error < + "argument types do not match, %0 != %1">; + Does `err_typecheck_call_different_arg_types`

[PATCH] D111985: [Clang] Add elementwise min/max builtins.

2021-10-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang/lib/Sema/SemaChecking.cpp:16695 + TheCall->setArg(1, B.get()); + TheCall->setType(TyB); + return false; I think you want to set this to `Res`, because that's the common type between `TyB` and `TyA`,

[PATCH] D111985: [Clang] Add elementwise min/max builtins.

2021-10-25 Thread Florian Hahn via Phabricator via cfe-commits
fhahn marked 4 inline comments as done. fhahn added inline comments. Comment at: clang/lib/Sema/SemaChecking.cpp:16669 +ExprResult Sema::SemaBuiltinElementwiseMath(CallExpr *TheCall, +ExprResult CallResult) { + if

[PATCH] D111985: [Clang] Add elementwise min/max builtins.

2021-10-25 Thread Florian Hahn via Phabricator via cfe-commits
fhahn updated this revision to Diff 382128. fhahn marked an inline comment as done. fhahn added a comment. Address comments @aaron.ballman, thanks! The most notable changes are using `UsualArithmeticConversions` for argument conversion and checking the canonical types. Also added a bunch of

[PATCH] D111985: [Clang] Add elementwise min/max builtins.

2021-10-25 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang/lib/Sema/SemaChecking.cpp:16673-16678 + Expr *A = TheCall->getArg(0); + Expr *B = TheCall->getArg(1); + QualType TyA = A->getType(); + QualType TyB = B->getType(); + + if (TyA != TyB) fhahn wrote: >

[PATCH] D111985: [Clang] Add elementwise min/max builtins.

2021-10-25 Thread Florian Hahn via Phabricator via cfe-commits
fhahn marked 6 inline comments as done. fhahn added inline comments. Comment at: clang/lib/Sema/SemaChecking.cpp:16673-16678 + Expr *A = TheCall->getArg(0); + Expr *B = TheCall->getArg(1); + QualType TyA = A->getType(); + QualType TyB = B->getType(); + + if (TyA != TyB)

[PATCH] D111985: [Clang] Add elementwise min/max builtins.

2021-10-25 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang/test/Sema/builtins-elementwise-math.c:42 + // expected-error@-1 {{argument types do not match, 'float4' (vector of 4 'float' values) != 'int3' (vector of 3 'int' values)}} +} aaron.ballman wrote: > fhahn

[PATCH] D111985: [Clang] Add elementwise min/max builtins.

2021-10-25 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang/lib/Sema/SemaChecking.cpp:16661 +Sema ) { + if (!Ty->getAs() && !ConstantMatrixType::isValidElementType(Ty)) { +S.Diag(Loc, diag::err_elementwise_math_invalid_arg_type) << Ty;

[PATCH] D111985: [Clang] Add elementwise min/max builtins.

2021-10-25 Thread Florian Hahn via Phabricator via cfe-commits
fhahn marked 5 inline comments as done. fhahn added a comment. Thanks for taking a look! Comment at: clang/lib/Sema/SemaChecking.cpp:16659-16660 +// false. +static bool checkMathBuiltinElementType(SourceLocation Loc, QualType Ty, +Sema )

[PATCH] D111985: [Clang] Add elementwise min/max builtins.

2021-10-25 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang/include/clang/Sema/Sema.h:12715-12716 + ExprResult SemaBuiltinElementwiseMath(CallExpr *TheCall, +ExprResult CallResult); + Why oh why did we start slapping `Sema`

[PATCH] D111985: [Clang] Add elementwise min/max builtins.

2021-10-25 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment. ping :) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111985/new/ https://reviews.llvm.org/D111985 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[PATCH] D111985: [Clang] Add elementwise min/max builtins.

2021-10-20 Thread Florian Hahn via Phabricator via cfe-commits
fhahn updated this revision to Diff 380946. fhahn added a comment. Move type checking to helper function checkMathBuiltinElementType to be reused in D111986 . Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION

[PATCH] D111985: [Clang] Add elementwise min/max builtins.

2021-10-18 Thread Florian Hahn via Phabricator via cfe-commits
fhahn updated this revision to Diff 380409. fhahn added a comment. polish tests a bit Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111985/new/ https://reviews.llvm.org/D111985 Files: clang/include/clang/Basic/Builtins.def

[PATCH] D111985: [Clang] Add elementwise min/max builtins.

2021-10-18 Thread Florian Hahn via Phabricator via cfe-commits
fhahn created this revision. fhahn added reviewers: aaron.ballman, scanon, craig.topper, rjmccall, erichkeane. fhahn requested review of this revision. Herald added a project: clang. This patch implements __builtin_elementwise_max and __builtin_elementwise_min, as specified in D111529