Arthur Eubanks [Fri, 26 Jun 2020 22:45:23 +0000 (15:45 -0700)]
Fix full-store-partial-alias.ll
Accidentally renamed -disable-basicaa -> -disable-basic-aa
Matt Arsenault [Fri, 26 Jun 2020 20:02:25 +0000 (16:02 -0400)]
LLParser: Accept align(N) as new syntax for parameter attribute
Every other value parameter attribute uses parentheses, so accept this
as the preferred modern syntax. Updating everything to use the new
syntax is left for a future change.
Matt Arsenault [Wed, 10 Jun 2020 14:40:35 +0000 (10:40 -0400)]
AMDGPU/GlobalISel: Fix some legalization of < dword vector stores
This avoids many instances of failing to legalize a vector truncstore
of <4 x s8> to 2 bytes. We don't perfectly handle every truncstore
yet, largely because the given set of legalization actions can't
actually differentiate between changing the result type and changing
the memory type.
Vedant Kumar [Fri, 26 Jun 2020 21:58:58 +0000 (14:58 -0700)]
Revert "[InstCombine] Drop debug loc in TryToSinkInstruction"
This reverts commit
903cf140d0118cf0d3f0f6f8967c6a20d9c5be6b.
This might be causing verifier failures on the bots, such as: "inlinable
function call in a function with debug info must have a !dbg location"
--
http://lab.llvm.org:8011/builders/sanitizer-ppc64be-linux/builds/16976/steps/bootstrap%20clang/logs/stdio
Arthur Eubanks [Fri, 26 Jun 2020 21:58:41 +0000 (14:58 -0700)]
[NewPM][BasicAA] basicaa -> basic-aa in Transforms/SLPVectorizer
Following https://reviews.llvm.org/D82607.
Reviewed By: ychen
Differential Revision: https://reviews.llvm.org/D82681
Arthur Eubanks [Fri, 26 Jun 2020 21:58:01 +0000 (14:58 -0700)]
[NewPM][BasicAA] basicaa -> basic-aa in Analysis/BasicAA
Following https://reviews.llvm.org/D82607.
Reviewed By: ychen
Differential Revision: https://reviews.llvm.org/D82683
Yuanfang Chen [Fri, 26 Jun 2020 21:55:00 +0000 (14:55 -0700)]
[MemorySSA] Update comment in PassBuilder
Is teaching the LoopFullUnrollPass to preserve MemorySSA very hard or
just impossible?
Reviewed By: asbirlea
Differential Revision: https://reviews.llvm.org/D82618
Vedant Kumar [Thu, 18 Jun 2020 21:17:07 +0000 (14:17 -0700)]
[debugify] Demote an error about empty locations to a warning
In https://reviews.llvm.org/D81198, we outlined a number of scenarios
where dropping debug locations is appropriate. Stop issuing an error
when this happens.
Steven Wu [Fri, 26 Jun 2020 21:53:23 +0000 (14:53 -0700)]
[compiler-rt] Fix mismatched #if/#endif comments
Fix a mismatched #if/#endif comments from my previous commit.
Matt Arsenault [Fri, 12 Jun 2020 12:49:18 +0000 (08:49 -0400)]
GlobalISel: Don't fail translate on weak cmpxchg
The translation of cmpxchg added by
9481399c0fd2c198c81b92636c0dcff7d4c41df2 specifically skipped weak
cmpxchg due to not understanding the meaning. Weak cmpxchg was added
in
420a216817def01816186910a2e35885c9201951. As explained in the
commit message, the weak mode is implicit in how
ATOMIC_CMP_SWAP_WITH_SUCCESS is lowered. If it's expanded to a regular
ATOMIC_CMP_SWAP, it's replaced with a strong cmpxchg.
This handling seems weird to me, but this was already following the
DAG behavior. I would expect the strong IR instruction to not have the
boolean output. Failing that, I might expect the IRTranslator to emit
ATOMIC_CMP_SWAP and a constant for the boolean.
Tony [Wed, 24 Jun 2020 08:11:01 +0000 (04:11 -0400)]
[AMDGPU] Define DWARF encoding for condition code registers
Summary:
- Define DWARF register numbers for vector and scalar condition codes.
- Document intended purpose of reserved DWARF register numbers.
Reviewers: yaxunl, kzhuravl, arsenm, rampitec, b-sumner
Subscribers: jvesely, wdng, nhaehnle, aprantl, dstuttard, tpr, kerbowa, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D82519
JF Bastien [Fri, 26 Jun 2020 20:48:51 +0000 (13:48 -0700)]
[NFC] Bump ObjCOrBuiltinIDBits to 15
We're now hitting this because we're at the limit for number of builtins:
clang/lib/Basic/IdentifierTable.cpp:39:1: error: static_assert failed due to requirement '2 * LargestBuiltinID < (2 << (ObjCOrBuiltinIDBits - 1))' "Insufficient ObjCOrBuiltinID Bits"
static_assert(2 * LargestBuiltinID < (2 << (ObjCOrBuiltinIDBits - 1)),
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Bump it to 15 so whoever adds a builtin next (as I am, or as anyone else might) doesn't merge conflict over each other.
Francesco Petrogalli [Fri, 26 Jun 2020 20:06:06 +0000 (20:06 +0000)]
[sve][acle] Recommit https://reviews.llvm.org/D82501
The original patch was reverted in
https://github.com/llvm/llvm-project/commit/
ff5ccf258e297df29f32d6b5e4fa0a7b95c44f9c
as it was missing the C tests that got accidentally missing.
This patch is a NFC of https://reviews.llvm.org/D82501, together with
the SVE ACLE tests for the C intrinsics of svreinterpret for brain
float types.
Amy Huang [Mon, 11 May 2020 21:13:37 +0000 (14:13 -0700)]
Extend or truncate __ptr32/__ptr64 pointers when dereferenced.
Summary:
A while ago I implemented the functionality to lower Microsoft __ptr32
and __ptr64 pointers, which are stored as 32-bit and 64-bit pointer
and are extended/truncated to the appropriate pointer size when
dereferenced.
This patch adds an addrspacecast to cast from the __ptr32/__ptr64
pointer to a default address space when dereferencing.
Bug: https://bugs.llvm.org/show_bug.cgi?id=42359
Reviewers: hans, arsenm, RKSimon
Subscribers: wdng, hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D81517
Vedant Kumar [Wed, 24 Jun 2020 18:33:28 +0000 (11:33 -0700)]
[InstCombine] Drop debug loc in TryToSinkInstruction
Summary:
The advice in HowToUpdateDebugInfo.rst is to "... preserve the debug
location of an instruction if the instruction either remains in its
basic block, or if its basic block is folded into a predecessor that
branches unconditionally".
TryToSinkInstruction doesn't seem to satisfy the criteria as it's
sinking an instruction to some successor block. Preserving the debug loc
can make single-stepping appear to go backwards, or make a breakpoint
hit on that location happen "too late" (since single-stepping from that
breakpoint can cause the function to return unexpectedly).
So, drop the debug location.
Reviewers: aprantl, davide
Subscribers: hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D82487
Francesco Petrogalli [Fri, 26 Jun 2020 20:10:15 +0000 (20:10 +0000)]
Revert "[sve][acle] Add reinterpret intrinsics for brain float."
This reverts commit
a15722c5ce4759c12960fe434ee6bd8aac70bb16.
The commmit has to be reverted because I accidentally submit
https://reviews.llvm.org/D82501 without the C tests that were added in
an early version of the patch.
Melanie Blower [Fri, 26 Jun 2020 20:17:45 +0000 (13:17 -0700)]
More corrections to documented spelling of ffinite-math to ffinite-math-only
Florian Hahn [Fri, 26 Jun 2020 16:51:51 +0000 (17:51 +0100)]
[VPlan] Add & use VPValue for VPWidenGEPRecipe operands (NFC).
This patch adds VPValue version of the GEP's operands to
VPWidenGEPRecipe and uses them during code-generation.
Reviewers: Ayal, gilr, rengolin
Reviewed By: gilr
Differential Revision: https://reviews.llvm.org/D80220
JF Bastien [Fri, 26 Jun 2020 19:58:17 +0000 (12:58 -0700)]
[NFC] Builtins: list 'R' for restrict
It was added to the list of builtin modifiers in r148573 back in 2012-01-20, but the comment wasn't updated.
Paul Walker [Sat, 20 Jun 2020 19:23:31 +0000 (20:23 +0100)]
[SVE] Code generation for fixed length vector adds.
Summary:
Teach LowerToPredicatedOp to lower fixed length vector operations.
Add AArch64ISD nodes and isel patterns for predicated integer
and floating point adds.
Together this enables SVE code generation for fixed length vector adds.
Reviewers: rengolin, efriedma
Subscribers: tschuett, kristof.beyls, hiraditya, rkruppe, psnobl, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D82483
Nick Desaulniers [Fri, 26 Jun 2020 19:52:43 +0000 (12:52 -0700)]
[clang][SourceManager] cache Macro Expansions
A seemingly innocuous Linux kernel change [0] seemingly blew up our
compile times by over 3x, as reported by @nathanchance in [1].
The code in question uses a doubly nested macro containing GNU C
statement expressions that are then passed to typeof(), which is then
used in a very important macro for atomic variable access throughout
most of the kernel. The inner most macro, is passed a GNU C statement
expression. In this case, we have macro arguments that are GNU C
statement expressions, which can contain a significant number of tokens.
The upstream kernel patch caused significant build time regressions for
both Clang and GCC. Since then, some of the nesting has been removed via
@melver, which helps gain back most of the lost compilation time. [2]
Profiles collected [3] from compilations of the slowest TU for us in the
kernel show:
* 51.4% time spent in clang::TokenLexer::updateLocForMacroArgTokens
* 48.7% time spent in clang::SourceManager::getFileIDLocal
* 35.5% time spent in clang::SourceManager::isOffsetInFileID
(mostly calls from the former through to the latter).
So it seems we have a pathological case for which properly tracking the
SourceLocation of macro arguments is significantly harming build
performance. This stands out in referenced flame graph.
In fact, this case was identified previously as being problematic in
commit
3339c568c4 ("[Lex] Speed up updateConsecutiveMacroArgTokens (NFC)")
Looking at the above call chain, there's 3 things we can do to speed up
this case.
1. TokenLexer::updateConsecutiveMacroArgTokens() calls
SourceManager::isWrittenInSameFile() which calls
SourceManager::getFileID(), which is both very hot and very expensive
to call. SourceManger has a one entry cache, member LastFileIDLookup.
If that isn't the FileID for a give source location offset, we fall
back to a linear probe, and then to a binary search for the FileID.
These fallbacks update the one entry cache, but noticeably they do
not for the case of macro expansions!
For the slowest TU to compile in the Linux kernel, it seems that we
miss about 78.67% of the 68 million queries we make to getFileIDLocal
that we could have had cache hits for, had we saved the macro
expansion source location's FileID in the one entry cache. [4]
I tried adding a separate cache item for macro expansions, and to
check that before the linear then binary search fallbacks, but did
not find it faster than simply allowing macro expansions into the one
item cache. This alone nets us back a lot of the performance loss.
That said, this is a modification of caching logic, which is playing
with a double edged sword. While it significantly improves the
pathological case, its hard to say that there's not an equal but
opposite pathological case that isn't regressed by this change.
Though non-pathological cases of builds of the Linux kernel before
[0] are only slightly improved (<1%) and builds of LLVM itself don't
change due to this patch.
Should future travelers find this change to significantly harm their
build times, I encourage them to feel empowered to revert this
change.
2. SourceManager::getFileIDLocal has a FIXME hinting that the call to
SourceManager::isOffsetInFileID could be made much faster since
isOffsetInFileID is generic in the sense that it tries to handle the
more generic case of "local" (as opposed to "loaded") files, though
the caller has already determined the file to be local. This patch
implements a new method that specialized for use when the caller
already knows the file is local, then use that in
TokenLexer::updateLocForMacroArgTokens. This should be less
controversial than 1, and is likely an across the board win. It's
much less significant for the pathological case, but still a
measurable win once we have fallen to the final case of binary
search. D82497
3. A bunch of methods in SourceManager take a default argument.
SourceManager::getLocalSLocEntry doesn't do anything with this
argument, yet many callers of getLocalSLocEntry setup, pass, then
check this argument. This is wasted work. D82498
With this patch applied, the above profile [5] for the same pathological
input looks like:
* 25.1% time spent in clang::TokenLexer::updateLocForMacroArgTokens
* 17.2% time spent in clang::SourceManager::getFileIDLocal
and clang::SourceManager::isOffsetInFileID is no longer called, and thus
falls out of the profile.
There may be further improvements to the general problem of "what
interval contains one number out of millions" than the current use of a
one item cache, followed by linear probing, followed by binary
searching. We might even be able to do something smarter in
TokenLexer::updateLocForMacroArgTokens.
[0] https://github.com/ClangBuiltLinux/linux/commit/
cdd28ad2d8110099e43527e96d059c5639809680
[1] https://github.com/ClangBuiltLinux/linux/issues/1032
[2] https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?h=locking/kcsan&id=
a5dead405f6be1fb80555bdcb77c406bf133fdc8
[3] https://github.com/ClangBuiltLinux/linux/issues/1032#issuecomment-
633712667
[4] https://github.com/ClangBuiltLinux/linux/issues/1032#issuecomment-
633741923
[5] https://github.com/ClangBuiltLinux/linux/issues/1032#issuecomment-
634932736
Reviewed By: kadircet
Differential Revision: https://reviews.llvm.org/D80681
Melanie Blower [Fri, 26 Jun 2020 19:47:58 +0000 (12:47 -0700)]
Correct documented spelling of ffinite-math to ffinite-math-only
This is to correct bugs.llvm.org/show_bug.cgi?id=46444
ffinite-math-only is a gcc option. That is the correct spelling.
File modified is clang/docs/UsersManual.rst
Roman Lebedev [Fri, 26 Jun 2020 19:40:30 +0000 (22:40 +0300)]
[CostModel] Avoid traditional ConstantExpr crashy pitfails
I'm not sure if this is a regression from D81448 + D81643,
which moved at least the code cast from elsewhere,
or somehow no one triggered that before.
But now we can reach it with a non-instruction..
It is not straight-forward to write cost-model tests for constantexprs,
`-cost-model -analyze -cost-kind=` does not appear to look at them,
or maybe i'm doing it wrong.
I've encountered that via a SimplifyCFG crash,
so reduced (currently-crashing) test is added.
There are likely other instances.
For now, simply restore previous status quo of
not crashing and returning TTI::TCC_Basic.
Louis Dionne [Fri, 26 Jun 2020 19:05:46 +0000 (15:05 -0400)]
[libc++] Remove support for building through llvm-config
We've decided to move away from that by requiring that libc++ is built
as part of the monorepo a while ago. This commit removes code pertaining
to that unsupported use case and produces a clear error when the user
violates that.
In fact, building outside of the monorepo will still work as long as
LLVM_PATH is pointing to the root of the LLVM project, although that
is not officially supported.
Matt Arsenault [Thu, 25 Jun 2020 01:01:55 +0000 (21:01 -0400)]
AMDGPU: Add llvm.amdgcn.sqrt intrinsic
I spread the GlobalISel test into the regular one, which I've been
avoiding so far.
David Tenty [Fri, 26 Jun 2020 18:49:24 +0000 (14:49 -0400)]
[NFCI] Cleanup range checks in Register/MCRegister
Summary:
by removing casts from unsigned to int that which may be implementation
defined according to C++14 (and thus trip up the XL compiler on AIX) by
just using unsigned comparisons/masks and refactor out the range
constants to cleanup things a bit while we are at it.
Reviewers: hubert.reinterpretcast, arsenm
Reviewed By: hubert.reinterpretcast
Subscribers: wdng, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D82197
Richard Barton [Fri, 26 Jun 2020 18:28:43 +0000 (19:28 +0100)]
[flang] Port remaining test_any.sh tests to FileCheck
Port the remaining tests which only require mechanical changes and delete
test_any.sh.
* Delete old RUN lines
* Replace:
EXEC: ${F18} ... | ${FileCheck} ...
with
RUN: %f18 .. | FileCheck ...
* Prepend RUN line with not when it is expected to fail
Also reinstate a de-activated EXEC line and port it in the same way.
Differential Revision: https://reviews.llvm.org/D82168
Sanjay Patel [Fri, 26 Jun 2020 18:20:40 +0000 (14:20 -0400)]
[DAGCombiner] rename variables for readability; NFC
PR46406 shows a pattern where we can do better, so try to clean this up
before adding more code.
Sanjay Patel [Thu, 25 Jun 2020 20:28:30 +0000 (16:28 -0400)]
[AArch64] add vector test for merged condition branching; NFC
Fangrui Song [Fri, 26 Jun 2020 18:18:18 +0000 (11:18 -0700)]
[CMake] Add check-debuginfo-* targets
* check-debuginfo-dexter runs lit tests under debuginfo-tests/dexter/
* check-debuginfo-llgdb-tests runs lit tests under debuginfo-tests/llgdb-tests/
* ...
Reviewed By: tbosch
Differential Revision: https://reviews.llvm.org/D82605
aartbik [Fri, 26 Jun 2020 18:03:11 +0000 (11:03 -0700)]
[mlir] [VectorOps] Add the ability to mark FP reductions with "reassociate" attribute
Rationale:
In general, passing "fastmath" from MLIR to LLVM backend is not supported, and even just providing such a feature for experimentation is under debate. However, passing fine-grained fastmath related attributes on individual operations is generally accepted. This CL introduces an option to instruct the vector-to-llvm lowering phase to annotate floating-point reductions with the "reassociate" fastmath attribute, which allows the LLVM backend to use SIMD implementations for such constructs. Oher lowering passes can start using this mechanism right away in cases where reassociation is allowed.
Benefit:
For some microbenchmarks on x86-avx2, speedups over 20 were observed for longer vector (due to cleaner, spill-free and SIMD exploiting code).
Usage:
mlir-opt --convert-vector-to-llvm="reassociate-fp-reductions"
Reviewed By: ftynse, mehdi_amini
Differential Revision: https://reviews.llvm.org/D82624
Amy Kwan [Fri, 26 Jun 2020 17:22:38 +0000 (12:22 -0500)]
[PowerPC] Add support for llvm.ppc.dcbt, llvm.ppc.dcbtst, llvm.ppc.isync intrinsics
This patch adds LLVM intrinsics for the dcbt (Data Cache Block Touch),
dcbtst (Data Cache Block Touch for Store) and isync (Instruction
Synchronize) instructions.
The intrinsic for dcbt and dcbst in this patch are named llvm.ppc.dcbt.with.hint
and llvm.ppc.dcbtst.with.hint respectively as there already exists an intrinsic
for llvm.ppc.dcbt and llvm.ppc.dcbtst. However, the original variants of the
intrinsics do not accept the TH immediate field, whereas these variants do.
Differential Revision: https://reviews.llvm.org/D79633
Eric Schweitz [Thu, 25 Jun 2020 22:42:50 +0000 (15:42 -0700)]
[flang] Add CHARACTER type lowering helpers and runtime.
In order for these files to build properly, this patch rolls up a number of changes that have been made to various files that have been upstreamed.
Implementations for the interfaces included in Bridge.h and IntrinsicCall.h will be included in a future diff.
Differential revision: https://reviews.llvm.org/D82608
Richard Barton [Fri, 26 Jun 2020 17:50:46 +0000 (18:50 +0100)]
[flang] Port test_any.sh tests to FileCheck: Hand port canondo{08-18} tests
These tests checked for stdout and stderr in the same pipe, which does not
come out in a guaranteed order. test_any.sh's FileCheck accepts CHECK lines in
any order while FileCheck checks must match in order.
Hand port these to pipe stdout to a temp file which is checked with a separate
FileCheck RUN line to test it.
Differential Revision: https://reviews.llvm.org/D82167
Richard Barton [Fri, 26 Jun 2020 17:49:21 +0000 (18:49 +0100)]
[flang] Port test_any.sh tests to FileCheck: Hand port getsymbols tests
test_any.sh's FileCheck accepts the CHECK line matches in any order while
FileCheck checks in strict order. Re-order the CHECK lines to source code
order - they come from an ordered datastructure.
Some CHECK lines are sensitive to line number which are fixed up manually.
getsymbols02 had multiple test inputs which had their own EXEC lines.
Consolidate these together in one file.
Differential Revision: https://reviews.llvm.org/D82166
Richard Barton [Fri, 26 Jun 2020 17:47:13 +0000 (18:47 +0100)]
[flang] Port test_any.sh tests to FileCheck: Hand port getdefinition* tests
These tests are sensitive to line numbers in the input and check output.
They also successively write to a temporary file then check that.
Fix the line number issues and replace the temporary file use with successive
calls to FileCheck with different check-prefixes.
Differential Revision: https://reviews.llvm.org/D82165
Rong Xu [Fri, 26 Jun 2020 17:20:09 +0000 (10:20 -0700)]
[PGO] Add a functionality to always instrument the func entry BB
Add an option to always instrument function entry BB (default off)
Add an option to do atomically updates on the first counter in each
instrumented function.
Differential Revision: https://reviews.llvm.org/D82123
Richard Barton [Fri, 5 Jun 2020 18:09:12 +0000 (19:09 +0100)]
[flang] Port test_any.sh tests to FileCheck: Hand port tests which use regexes
The regex syntax used by test_any.sh's FileCheck is sometimes incompatible with
real FileCheck.
Hand port these tests to use FileCheck and it's regex format.
Also remove FIXME from label01 that no longer applies.
Also add second run-line that enables all tests.
Add some new FIXMEs for issues in original tests
Differential Revision: https://reviews.llvm.org/D82164
Philip Reames [Thu, 25 Jun 2020 23:40:29 +0000 (16:40 -0700)]
Migrate last batch of tests to gc-live bundle format
For context of anyone following along, we've not completed the migration of statepoint to the operand bundle form. The only remaining piece is to actually version the statepoint intrinsic to remove the old inline operand sets. That will follow when I have some time; delay is useful here to allow downstream migrations.
Nico Weber [Fri, 26 Jun 2020 17:25:45 +0000 (13:25 -0400)]
Revert "[clang driver] Move default module cache from system temporary directory"
This reverts commit
bb26838ceffb5feaa18186f55f7525a08084899e.
Breaks Support.CacheDirectoryNoEnv, Support.CacheDirectoryWithEnv
in SupportTests (part of check-llvm) on macOS.
Nick Desaulniers [Fri, 26 Jun 2020 17:22:26 +0000 (10:22 -0700)]
[SourceManager] don't check invalid param of getLocalSLocEntry()
Forked from D80681.
getLocalSLocEntry() has an unused parameter used to satisfy an interface
of libclang (see getInclusions() in
clang/tools/libclang/CIndexInclusionStack.cpp). It's pointless for
callers to construct/pass/check this inout parameter that can never
signify that a FileID is invalid.
Reviewed By: kadircet
Differential Revision: https://reviews.llvm.org/D82498
Arthur Eubanks [Fri, 26 Jun 2020 16:28:32 +0000 (09:28 -0700)]
[NewPM][LoopUnroll] Rename unroll* to loop-unroll*
The legacy pass is called "loop-unroll", but in the new PM it's called "unroll".
Also applied to unroll-and-jam and unroll-full.
Fixes various check-llvm tests when NPM is turned on.
Reviewed By: Whitney, dmgreen
Differential Revision: https://reviews.llvm.org/D82590
Kit Barton [Tue, 9 Jun 2020 21:18:02 +0000 (16:18 -0500)]
[PPC][NFC] Add Subtarget and replace all uses of PPCSubTarget with Subtarget.
Summary:
In preparation for GlobalISel, PPCSubTarget needs to be renamed to Subtarget as there places in GlobalISel that assume the presence of the variable Subtarget.
This patch introduces the variable Subtarget, and replaces all existing uses of PPCSubTarget with Subtarget. A subsequent patch will remove the definiton of
PPCSubTarget, once any downstream users have the opportunity to rename any uses they have.
Reviewers: hfinkel, nemanjai, jhibbits, #powerpc, echristo, lkail
Reviewed By: #powerpc, echristo, lkail
Subscribers: echristo, lkail, wuzish, nemanjai, hiraditya, jfb, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D81623
Yitzhak Mandelbaum [Fri, 26 Jun 2020 16:17:28 +0000 (16:17 +0000)]
[libTooling] Improve error message from failure in selection Stencil
This patch improves the error message provided by the stencil that handles
source from a range selector.
Reviewed By: gribozavr2
Differential Revision: https://reviews.llvm.org/D82654
Louis Dionne [Fri, 26 Jun 2020 15:49:44 +0000 (11:49 -0400)]
[libc++abi] Fix build failure in abort_message.cpp when vasprintf isn't provided
Melanie Blower [Fri, 26 Jun 2020 15:45:12 +0000 (08:45 -0700)]
Revert "Revert "Revert "Modify FPFeatures to use delta not absolute settings"""
This reverts commit
9518763d710bfbbf9315fa88972c55898be44a0e.
Memory sanitizer fails in CGFPOptionsRAII::CGFPOptionsRAII dtor
sstefan1 [Fri, 26 Jun 2020 15:32:06 +0000 (15:32 +0000)]
[OpenMPOpt][NFC] Change ICV macros for initial value
This fixes build breaks when system headers are difining FALSE.
Francesco Petrogalli [Wed, 24 Jun 2020 15:48:10 +0000 (15:48 +0000)]
[sve][acle] Add reinterpret intrinsics for brain float.
Reviewers: kmclaughlin, efriedma, ctetreau, sdesmalen, david-arm
Subscribers: tschuett, hiraditya, rkruppe, psnobl, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D82501
Kevin P. Neal [Fri, 26 Jun 2020 15:06:48 +0000 (11:06 -0400)]
[NFC] Eliminate an unneeded -vv used in test development.
Thomas Raoux [Fri, 26 Jun 2020 14:59:17 +0000 (07:59 -0700)]
[mlir][vulkan-runner] Make vulkan runner use GPU device memory
To be able to have more meaningful performance out of workloadsi going through
the vulkan-runner we need to use buffers from GPU device memory as access to
system memory is significantly slower for GPU with dedicated memory. This adds
code to do a copy through staging buffer as GPU memory cannot always be mapped
on the host.
Differential Revision: https://reviews.llvm.org/D82504
Melanie Blower [Fri, 26 Jun 2020 14:54:01 +0000 (07:54 -0700)]
Revert "Revert "Modify FPFeatures to use delta not absolute settings""
This reverts commit
b55d723ed61052b77e720dcffecac43abe873186.
Reapply Modify FPFeatures to use delta not absolute settings
To solve https://bugs.llvm.org/show_bug.cgi?id=46166 where the
floating point settings in PCH files aren't compatible, rewrite
FPFeatures to use a delta in the settings rather than absolute settings.
With this patch, these floating point options can be benign.
Reviewers: rjmccall
Differential Revision: https://reviews.llvm.org/D81869
Vy Nguyen [Thu, 25 Jun 2020 15:15:16 +0000 (11:15 -0400)]
[llvm-exegesis] Let Counter returns up to 16 entries
LBR contains (up to) 16 entries for last x branches and the X86LBRCounter (from D77422) should be able to return all those.
Currently, it just returns the latest entry, which could lead to mis-leading measurements.
This patch aslo changes the LatencyBenchmarkRunner to accommodate multi-value readings.
https://reviews.llvm.org/D81050
Melanie Blower [Fri, 26 Jun 2020 14:48:38 +0000 (07:48 -0700)]
Revert "Modify FPFeatures to use delta not absolute settings"
This reverts commit
3a748cbf86cea3844fada04eeff4cc64b01f67e0.
I'm reverting this commit because I forgot to format the commit message
propertly. Sorry for the thrash.
Dmitri Gribenko [Fri, 26 Jun 2020 10:09:11 +0000 (12:09 +0200)]
Work around a bug in MSVC in the syntax tree test
Summary:
MSVC does not handle raw string literals with embedded double quotes
correctly. I switched the affected test case to use regular string
literals insetad.
Subscribers: cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D82636
Melanie Blower [Mon, 15 Jun 2020 19:43:37 +0000 (12:43 -0700)]
Modify FPFeatures to use delta not absolute settings
George Mitenkov [Fri, 26 Jun 2020 14:29:05 +0000 (10:29 -0400)]
[MLIR][SPIRVToLLVM] Conversion for bitrverse and bitcount ops
Implemented conversion for `spv.BitReverse` and `spv.BitCount`. Since ODS
generates builders in a different way for LLVM dialect intrinsics, I
added attributes to build method in `DirectConversionPattern` class. The
tests for these ops are in `bitwise-ops-to-llvm.mlir`.
Differential Revision: https://reviews.llvm.org/D82286
Yitzhak Mandelbaum [Fri, 26 Jun 2020 14:23:25 +0000 (14:23 +0000)]
[libTooling] Rename overloaded `range` range selector.
Renames the overloaded `RangeSelector` combinator `range` to the more
descriptive `enclose` and `encloseNodes`. The old overloads are left in place
and marked deprected and will be deleted at a future time.
Reviewed By: tdl-g
Differential Revision: https://reviews.llvm.org/D82592
Guillaume Chatelet [Fri, 26 Jun 2020 14:14:27 +0000 (14:14 +0000)]
[Alignment][NFC] Migrate TTI::isLegalToVectorize{Load,Store}Chain to Align
This is patch is part of a series to introduce an Alignment type.
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790
Differential Revision: https://reviews.llvm.org/D82653
Matt Arsenault [Fri, 26 Jun 2020 13:02:46 +0000 (09:02 -0400)]
AMDGPU/GlobalISel: Fix legacy clover kernel argument ABI
This had an extra attempt to align the pointer, which only did
anything with a base kernel argument offset which only clover used to
use.
Matt Arsenault [Fri, 26 Jun 2020 13:22:03 +0000 (09:22 -0400)]
AMDGPU/GlobalISel: Add baseline checks for legacy clover kernel ABI
I'm not sure we actually need to support this now, since I think
clover always explicitly uses amdgcn-mesa-mesa3d now, not the
ill-defined amdgcn-- behavior.
Matt Arsenault [Fri, 26 Jun 2020 13:30:10 +0000 (09:30 -0400)]
AMDGPU/GlobalISel: Uncomment some fixed tests
Denis Khalikov [Fri, 26 Jun 2020 13:49:09 +0000 (09:49 -0400)]
[mlir][spirv] Add RewriteInserts pass.
Add a pass to rewrite sequential chains of `spirv::CompositeInsert`
operations into `spirv::CompositeConstruct` operations.
Reviewed By: antiagainst
Differential Revision: https://reviews.llvm.org/D82198
Kadir Cetinkaya [Fri, 26 Jun 2020 13:38:15 +0000 (15:38 +0200)]
[CodeComplete] Add code completion for using alias.
Add code completion for using alias.
Patch By @lh123 !
Reviewers: kadircet
Differential Revision: https://reviews.llvm.org/D82535
Kerry McLaughlin [Fri, 26 Jun 2020 12:55:46 +0000 (13:55 +0100)]
[AArch64][SVE] Remove asserts from AArch64ISelLowering for bfloat16 types
Remove the asserts in performLDNT1Combine & performST[NT]1Combine
to ensure we get a failure where the type is a bfloat16 and
hasBF16() is false, regardless of whether asserts are enabled.
serge-sans-paille [Fri, 26 Jun 2020 13:23:05 +0000 (15:23 +0200)]
Fix pass return status for loop extractor
As loop extractor has a dependency on another pass (namely BreakCriticalEdges)
that may update the IR, use the getAnalysis version introduced in
55fe7b79bb7fab49af3720840224c0720bdb03c6 to carry that change.
Add an assert in getAnalysisID to make sure no other changed status is missed -
according to validation this was the only one.
Related to https://reviews.llvm.org/D80916
Differential Revision: https://reviews.llvm.org/D81236
Simon Pilgrim [Fri, 26 Jun 2020 13:46:20 +0000 (14:46 +0100)]
Revert rGf0bab7875e78e01c149d12302dcc4b6d4c43e25c - "Triple.h - reduce Twine.h include to forward declarations. NFC."
This causes ICEs on the clang-ppc64be buildbots and I've limited ability to triage the problem.
ergawy [Fri, 26 Jun 2020 13:37:30 +0000 (09:37 -0400)]
[MLIR][SPIRV] Add support for OpCopyMemory.
This patch add support for 'spv.CopyMemory'. The following changes are
introduced:
- 'CopyMemory' op is added to SPIRVOps.td.
- Custom parse and print methods are introduced.
- A few Roundtripping tests are added.
Differential Revision: https://reviews.llvm.org/D82384
Tobias Gysi [Fri, 26 Jun 2020 11:46:37 +0000 (13:46 +0200)]
[mlir] fix off-by-one error in collapseParallelLoops
Summary: The patch fixes an off by one error in the method collapseParallelLoops. It ensures the same normalized bound is used for the computation of the division and the remainder.
Reviewers: herhut
Reviewed By: herhut
Subscribers: mehdi_amini, rriddle, jpienaar, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, aartbik, liufengdb, stephenneuendorffer, Joonsoo, grosul1, Kayjukh, jurahul, msifontes
Tags: #mlir
Differential Revision: https://reviews.llvm.org/D82634
Alex Zinenko [Fri, 26 Jun 2020 12:47:38 +0000 (14:47 +0200)]
[mlir] Avoid creating local OpBuilders in Standard-to-LLVM conversion
Conversions of allocation-related operations in Standard-to-LLVM need
declarations of "malloc" and "free" (or equivalents). They use locally created
OpBuilders pointed at the module level to declare these functions if necessary.
This is poorly compatible with the pattern infrastructure that is unaware of
new operations being created. Update the insertion point of the main rewriter
instead.
Differential Revision: https://reviews.llvm.org/D82649
Alex Zinenko [Fri, 26 Jun 2020 12:34:00 +0000 (14:34 +0200)]
[mlir] support returning unranked memrefs
Initially, unranked memref descriptors in the LLVM dialect were designed only
to be passed into functions. An assertion was guarding against returning
unranked memrefs from functions in the standard-to-LLVM conversion. This is
insufficient for functions that wish to return an unranked memref such that the
caller does not know the rank in advance, and hence cannot allocate the
descriptor and pass it in as an argument.
Introduce a calling convention for returning unranked memref descriptors as
follows. An unranked memref descriptor always points to a ranked memref
descriptor stored on stack of the current function. When an unranked memref
descriptor is returned from a function, the ranked memref descriptor it points
to is copied to dynamically allocated memory, the ownership of which is
transferred to the caller. The caller is responsible for deallocating the
dynamically allocated memory and for copying the pointed-to ranked memref
descriptor onto its stack.
Provide default lowerings for std.return, std.call and std.indirect_call that
maintain the conversion defined above.
This convention is additionally exercised by a runtime test to guard against
memory errors.
Differential Revision: https://reviews.llvm.org/D82647
Raphael Isemann [Fri, 26 Jun 2020 13:24:04 +0000 (15:24 +0200)]
[lldb] Re-add X-Fail for Windows to TestDollarInVariable
This got removed by accident in
048d11de43be087fd2fa0c5e35f20486f6094c29 when
the test was rewritten as a non-inline test.
Simon Pilgrim [Fri, 26 Jun 2020 13:13:30 +0000 (14:13 +0100)]
Add explicit Twine.h include to try and fix ICE on clang-ppc64be-linux
Jean-Michel Gorius [Fri, 26 Jun 2020 11:20:44 +0000 (13:20 +0200)]
[mlir-tblgen] Use fully qualified names in generated code files
Using fully qualified names wherever possible avoids ambiguous class and function names. This is a follow-up to D82371.
Reviewed By: rriddle
Differential Revision: https://reviews.llvm.org/D82471
Tung D. Le [Wed, 24 Jun 2020 16:56:05 +0000 (22:26 +0530)]
[MLIR][Affine-loop-fusion] Fix a bug in affine-loop-fusion pass when there are non-affine operations
When there is a mix of affine load/store and non-affine operations (e.g. std.load, std.store),
affine-loop-fusion ignores the present of non-affine ops, thus changing the program semantics.
E.g. we have a program of three affine loops operating on the same memref in which one of them uses std.load and std.store, as follows.
```
affine.for
affine.store %1
affine.for
std.load %1
std.store %1
affine.for
affine.load %1
affine.store %1
```
affine-loop-fusion will produce the following result which changed the program semantics:
```
affine.for
std.load %1
std.store %1
affine.for
affine.store %1
affine.load %1
affine.store %1
```
This patch is to fix the above problem by checking non-affine users of the memref that are between the source and destination nodes of interest.
Differential Revision: https://reviews.llvm.org/D82158
Simon Tatham [Fri, 26 Jun 2020 12:47:33 +0000 (13:47 +0100)]
Fix implicit include dependencies on SmallVector.h.
Both `AArch64TargetParser.h` and `ARMTargetParser.h` refer to
`SmallVectorImpl` without directly including the header that defines
it, which works fine until nothing else happens to include it anyway.
Cullen Rhodes [Wed, 24 Jun 2020 16:56:37 +0000 (16:56 +0000)]
[AArch64][SVE] Only support sizeless bfloat types if supported by subtarget
Reviewers: sdesmalen, efriedma, kmclaughlin, fpetrogalli
Reviewed By: sdesmalen, fpetrogalli
Differential Revision: https://reviews.llvm.org/D82494
Anatoly Trosinenko [Fri, 26 Jun 2020 12:32:01 +0000 (15:32 +0300)]
[MSP430] Update register names
When writing a unit test on replacing standard epilogue sequences with `BR __mspabi_func_epilog_<N>`, by manually asm-clobbering `rN` - `r10` for N = 4..10, everything worked well except for seeming inability to clobber r4.
The problem was that MSP430 code generator of LLVM used an obsolete name FP for that register. Things were worse because when `llc` read an unknown register name, it silently ignored it.
That is, I cannot use `fp` register name from the C code because Clang does not accept it (exactly like GCC). But the accepted name `r4` is not recognised by `llc` (it can be used in listings passed to `llvm-mc` and even `fp` is replace to `r4` by `llvm-mc`). So I can specify any of `fp` or `r4` for the string literal of `asm(...)` but nothing in the clobber list.
This patch replaces `MSP430::FP` with `MSP430::R4` in the backend code (even [MSP430 EABI](http://www.ti.com/lit/an/slaa534/slaa534.pdf) doesn't mention FP as a register name). The R0 - R3 registers, on the other hand, are left as is in the backend code (after all, they have some special meaning on the ISA level). It is just ensured clang is renaming them as expected by the downstream tools. There is probably not much sense in **marking them clobbered** but rename them //just in case// for use at potentially different contexts.
Differential Revision: https://reviews.llvm.org/D82184
Anatoly Trosinenko [Fri, 26 Jun 2020 12:31:04 +0000 (15:31 +0300)]
[builtins] Improve compatibility with 16 bit targets
Some parts of existing codebase assume the default `int` type to be (at least) 32 bit wide. On 16 bit targets such as MSP430 this may cause Undefined Behavior or results being defined but incorrect.
Differential Revision: https://reviews.llvm.org/D81408
Simon Pilgrim [Fri, 26 Jun 2020 12:23:53 +0000 (13:23 +0100)]
Fix implicit Twine.h include dependency.
serge-sans-paille [Fri, 26 Jun 2020 11:07:31 +0000 (13:07 +0200)]
Improve LegacyPassManager API to correctly report modified status
When calling on-the-fly passes from the legacy pass manager, the modification
status is not reported, which is a problem in case we depend on an acutal
transformation pass, and not only analyse.
Update the Legacy PM API to optionally report the changed status, assert if a
change is detected but this change is lost.
Related to https://reviews.llvm.org/D80916
Differential Revision: https://reviews.llvm.org/D81236
Simon Pilgrim [Fri, 26 Jun 2020 11:59:08 +0000 (12:59 +0100)]
Triple.h - reduce Twine.h include to forward declarations. NFC.
Move include down to a number of other files that had an implicit dependency on the Twine class.
David Zarzycki [Tue, 23 Jun 2020 09:43:51 +0000 (05:43 -0400)]
[clang driver] Move default module cache from system temporary directory
1) Shared writable directories like /tmp are a security problem.
2) Systems provide dedicated cache directories these days anyway.
3) This also refines LLVM's cache_directory() on Darwin platforms to use
the Darwin per-user cache directory.
Reviewers: compnerd, aprantl, jakehehrlich, espindola, respindola, ilya-biryukov, pcc, sammccall
Reviewed By: compnerd, sammccall
Subscribers: hiraditya, llvm-commits, cfe-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D82362
Bevin Hansson [Wed, 22 Jan 2020 13:53:11 +0000 (14:53 +0100)]
[AST] Fix certain consteval assignment and comma operator issues with fixed-point types.
Summary:
Assignment and comma operators for fixed-point types were being constevaled as other
binary operators, but they need special treatment.
Reviewers: rjmccall, leonardchan, bjope
Subscribers: cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D73189
Bevin Hansson [Wed, 22 Jan 2020 12:20:12 +0000 (13:20 +0100)]
[AST] Improve overflow diagnostics for fixed-point constant evaluation.
Summary:
Diagnostics for overflow were not being produced for fixed-point
evaluation. This patch refactors a bit of the evaluator and adds
a proper diagnostic for these cases.
Reviewers: rjmccall, leonardchan, bjope
Subscribers: cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D73188
Bevin Hansson [Wed, 22 Jan 2020 09:10:54 +0000 (10:10 +0100)]
[AST] Add fixed-point division constant evaluation.
Reviewers: rjmccall, leonardchan, bjope
Subscribers: cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D73187
Bevin Hansson [Tue, 21 Jan 2020 13:17:30 +0000 (14:17 +0100)]
[AST] Add fixed-point multiplication constant evaluation.
Reviewers: rjmccall, leonardchan, bjope
Subscribers: cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D73186
Bevin Hansson [Fri, 10 Jan 2020 12:54:58 +0000 (13:54 +0100)]
[AST] Add fixed-point subtraction constant evaluation.
Reviewers: rjmccall, leonardchan
Subscribers: cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D73185
Simon Pilgrim [Fri, 26 Jun 2020 10:46:52 +0000 (11:46 +0100)]
TargetSubtargetInfo.h - remove unnecessary forward declarations. NFC.
We have to include MCSubtargetInfo.h
Simon Pilgrim [Fri, 26 Jun 2020 10:32:57 +0000 (11:32 +0100)]
MemorySSAUpdater.h - remove unnecessary WeakVH forward declaration. NFC.
We have to include ValueHandle.h
Xing GUO [Fri, 26 Jun 2020 11:24:25 +0000 (19:24 +0800)]
[DWARFYAML][debug_info] Teach yaml2obj emit correct DWARF64 unit header.
This patch helps teach yaml2obj emit correct DWARF64 unit header of the .debug_info section.
Reviewed By: jhenderson
Differential Revision: https://reviews.llvm.org/D82621
Guillaume Chatelet [Fri, 26 Jun 2020 11:08:27 +0000 (11:08 +0000)]
[Alignment][NFC] Migrate TTI::getGatherScatterOpCost to Align
This is patch is part of a series to introduce an Alignment type.
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790
Differential Revision: https://reviews.llvm.org/D82577
Guillaume Chatelet [Fri, 26 Jun 2020 11:00:53 +0000 (11:00 +0000)]
[Alignment][NFC] Migrate TTI::getInterleavedMemoryOpCost to Align
This is patch is part of a series to introduce an Alignment type.
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790
Differential Revision: https://reviews.llvm.org/D82573
Raphael Isemann [Fri, 26 Jun 2020 10:55:42 +0000 (12:55 +0200)]
[lldb][NFC] Make TestDollarInVariable a non-inline test
Jay Foad [Fri, 26 Jun 2020 10:29:10 +0000 (11:29 +0100)]
[AMDGPU] Use std::pair to return two values. NFC.
Cullen Rhodes [Thu, 25 Jun 2020 16:01:00 +0000 (16:01 +0000)]
[AArch64][SVE2] Guard while intrinsics on scalar bfloat feature macro
Summary:
`svwhilerw_bf16` and `svwhilewr_bf16` intrinsics use the scalar
`bfloat16_t`
type which is predicated on `__ARM_FEATURE_BF16_SCALAR_ARITHMETIC`. This
patch changes the feature guard from `__ARM_FEATURE_SVE_BF16` to the
scalar bfloat feature macro.
The verify tests for `+bf16` are also removed in this patch. The purpose
of these checks was to match the SVE2 ACLE tests that look for an
implicit declaration warning if the feature isn't set. They worked when
the intrinsics were guarded on `__ARM_FEATURE_SVE_BF16` as the
`bfloat16_t`
was guarded on a different macro, but with both the type and intrinsic
guarded on the same macro an earlier error is triggered in the ACLE
regarding the type and we don't get a warning as we do for SVE2.
Reviewers: sdesmalen, fpetrogalli, kmclaughlin, rengolin, efriedma
Reviewed By: sdesmalen, fpetrogalli
Differential Revision: https://reviews.llvm.org/D82578
Guillaume Chatelet [Fri, 26 Jun 2020 10:14:16 +0000 (10:14 +0000)]
[Alignment][NFC] Migrate TTI::getMaskedMemoryOpCost to Align
This is patch is part of a series to introduce an Alignment type.
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790
Differential Revision: https://reviews.llvm.org/D82569
Kerry McLaughlin [Fri, 26 Jun 2020 09:47:18 +0000 (10:47 +0100)]
[AArch64][SVE] Add bfloat16 support to store intrinsics
Summary:
Bfloat16 support added for the following intrinsics:
- ST1
- STNT1
Reviewers: sdesmalen, c-rhodes, fpetrogalli, efriedma, stuij, david-arm
Reviewed By: fpetrogalli
Subscribers: tschuett, kristof.beyls, hiraditya, rkruppe, psnobl, danielkiss, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D82448
Simon Pilgrim [Fri, 26 Jun 2020 09:48:40 +0000 (10:48 +0100)]
LoopVectorize.h - reduce AliasAnalysis.h include to forward declaration. NFC.
Replace legacy AliasAnalysis typedef with AAResults where necessary.
Pavel Labath [Tue, 23 Jun 2020 13:40:36 +0000 (15:40 +0200)]
[lldb/Unwind] Use eh_frame plan directly when it doesn't need to be augmented
Summary:
This fixes a bug in the logic for choosing the unwind plan. Based on the
comment in UnwindAssembly-x86, the intention was that a plan which
describes the function epilogue correctly does not need to be augmented
(and it should be used directly). However, the way this was implemented
(by returning false) meant that the higher level code
(FuncUnwinders::GetEHFrameAugmentedUnwindPlan) interpreted this as a
failure to produce _any_ plan and proceeded with other fallback options.
The fallback usually chosed for "asynchronous" plans was the
"instruction emulation" plan, which tended to fall over on certain
functions with multiple epilogues (that's a separate bug).
This patch simply changes the function to return true, which signals the
caller that the unmodified plan is ready to be used.
The attached test case demonstrates the case where we would previously
fall back to the instruction emulation plan, and unwind incorrectly --
the test asserts that the "augmented" eh_frame plan is used, and that
the unwind is correct.
Reviewers: jasonmolenda, jankratochvil
Subscribers: davide, echristo, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D82378
Pavel Labath [Fri, 26 Jun 2020 09:32:22 +0000 (11:32 +0200)]
[lldb] Rewrite Scalar::Promote
This function was implementing c-like promotion rules by switching on
the both types. C promotion rules are complicated, but they are not
*that* complicated -- they basically boil down to:
- wider types trump narrower ones
- unsigned trump signed
- floating point trumps integral
With a couple of helper functions, we can rewrite the function in terms
of these rules and greatly reduce the size and complexity of this
function.