162 Commits

Author SHA1 Message Date
Benjamin Kramer
f3ff35c66b [MIPS GlobalISel] Silence uninitialized variable warning
The control flow here cannot ever use the uninitialized value, but it's
too hard for the compiler to figure that out. Clang warns:

llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp:2600:28: error: variable 'CarrySum' is used uninitialized whenever 'for' loop exits because its condition is false [-Werror,-Wsometimes-uninitialized]
      for (unsigned i = 2; i < Factors.size(); ++i)
                           ^~~~~~~~~~~~~~~~~~
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp:2604:26: note: uninitialized use occurs here
    CarrySumPrevDstIdx = CarrySum;
                         ^~~~~~~~
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp:2600:28: note: remove the condition if it is always true
      for (unsigned i = 2; i < Factors.size(); ++i)
                           ^~~~~~~~~~~~~~~~~~
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp:2583:22: note: initialize the variable 'CarrySum' to silence this warning
    unsigned CarrySum;
                     ^
                      = 0

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355818 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-11 10:39:15 +00:00
Petar Avramovic
e7f4ae297e [MIPS GlobalISel] NarrowScalar G_UMULH
NarrowScalar G_UMULH in LegalizerHelper 
using multiplyRegisters helper function.
NarrowScalar G_UMULH for MIPS32.

Differential Revision: https://reviews.llvm.org/D58825


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355815 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-11 10:08:44 +00:00
Petar Avramovic
4306b0ed95 [MIPS GlobalISel] NarrowScalar G_MUL
Narrow Scalar G_MUL for MIPS32.
Revisit NarrowScalar implementation in LegalizerHelper.
Introduce new helper function multiplyRegisters.
It performs generic multiplication of values held in multiple registers.
Generated instructions use only types NarrowTy and i1.
Destination can be same or two times size of the source.

Differential Revision: https://reviews.llvm.org/D58824


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355814 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-11 10:00:17 +00:00
Matt Arsenault
2d429b1091 GlobalISel: Implement fewerElementsVector for phi
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355048 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-28 00:16:32 +00:00
Matt Arsenault
0d2ad48b33 GlobalISel: Implement moreElementsVector for phi
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355047 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-28 00:01:05 +00:00
Petar Avramovic
7e18e3836e [MIPS GlobalISel] Select G_UADDO
Lower G_UADDO.
Legalize G_UADDO for MIPS32

Differential Revision: https://reviews.llvm.org/D58671


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354900 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-26 17:22:42 +00:00
Matt Arsenault
1b59f4c380 GlobalISel: Fix fewerElementsVector for ctlz with different result type
Also complete the set of related operations.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354480 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-20 16:42:52 +00:00
Matt Arsenault
7e1a65dad5 GlobalISel: Implement moreElementsVector for g_insert results
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354477 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-20 16:11:22 +00:00
Matt Arsenault
379689ce0c GlobalISel: Implement moreElementsVector for select
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354354 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-19 17:03:09 +00:00
Matt Arsenault
406dc2a0d5 GlobalISel: Implement moreElementsVector for G_EXTRACT source
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354348 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-19 16:44:22 +00:00
Matt Arsenault
47f8b7cd25 GlobalISel: Implement moreElementsVector for bit ops
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354345 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-19 16:30:19 +00:00
Jessica Paquette
1d3cbd7331 [GlobalISel][AArch64] Legalize + select some llvm.ctlz.* intrinsics
Legalize/select llvm.ctlz.*

Add select-ctlz to show that we actually select them. Update arm64-clrsb.ll and
arm64-vclz.ll to show that we perform valid transformations in optimized builds,
and document where GISel can improve.

Differential Revision: https://reviews.llvm.org/D58155

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354299 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-18 23:33:24 +00:00
Matt Arsenault
b1b624d08a GlobalISel: Implement widenScalar for g_extract scalar results
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354293 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-18 22:39:27 +00:00
Matt Arsenault
57d9165df0 GlobalISel: Fix double count of offset for irregular vector breakdowns
Fixes cases with odd vectors that break into multiple requested size
pieces.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354280 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-18 17:01:09 +00:00
Petar Avramovic
e817e7373a [MIPS GlobalISel] Select branch instructions
Select G_BR and G_BRCOND for MIPS32.
Unconditional branch G_BR does not have register operand,
for that reason we only add tests.
Since conditional branch G_BRCOND compares register to zero on MIPS32,
explicit extension must be performed on i1 condition in order to set
high bits to appropriate value.

Differential Revision: https://reviews.llvm.org/D58182


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354022 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-14 11:39:53 +00:00
Matt Arsenault
bfe35f840d GlobalISel: Use default rounding mode when extending fconstant
I don't think this matters since the values should all be exactly
representable.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353844 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-12 14:54:54 +00:00
Matt Arsenault
31cd6654ed GlobalISel: Move some more legalize cases into functions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353843 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-12 14:54:52 +00:00
Matt Arsenault
f3f4691605 GlobalISel: Implement moreElementsVector for implicit_def
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353754 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-11 22:00:39 +00:00
Matt Arsenault
3038811553 GlobalISel: Fix not calling the observer when legalizing G_EXTRACT
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353750 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-11 21:33:54 +00:00
Jessica Paquette
baeeed43cc [GlobalISel][AArch64] Select G_FFLOOR
This teaches the legalizer about G_FFLOOR, and lets us select G_FFLOOR in
AArch64.

It updates the existing floating point tests, and adds a select-floor.mir test.

Differential Revision: https://reviews.llvm.org/D57486

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353722 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-11 17:22:58 +00:00
Matt Arsenault
c0665d4bcd GlobalISel: Add G_FCANONICALIZE instruction
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353719 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-11 17:05:20 +00:00
Petar Avramovic
005af434d1 [MIPS GlobalISel] Select any extending load and truncating store
Make behavior of G_LOAD in widenScalar same as for G_ZEXTLOAD and
G_SEXTLOAD. That is perform widenScalarDst to size given by the target
and avoid additional checks in common code. Targets can reorder or add
additional rules in LegalizeRuleSet for the opcode to achieve desired
behavior.

Select extending load that does not have specified type of extension
into zero extending load.

Select truncating store that stores number of bytes indicated by size
in MachineMemoperand.

Differential Revision: https://reviews.llvm.org/D57454


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353520 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-08 14:27:23 +00:00
Matt Arsenault
e6576d59f1 AMDGPU/GlobalISel: Legalize addrspacecast
Use a placeholder constant for now on targets
that need the load from the queue ptr.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353497 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-08 02:40:47 +00:00
Matt Arsenault
ef001e8e8a GlobalISel: Try to fix bot failures
Don't rely on order of evaluation of function arguments.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353460 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-07 20:44:08 +00:00
Matt Arsenault
c0f816e09c GlobalISel: Implement narrowScalar for shift main type
This is pretty much directly ported from SelectionDAG. Doesn't include
the shift by non-constant but known bits version, since there isn't a
globalisel version of computeKnownBits yet.

This shows a disadvantage of targets not specifically which type
should be used for the shift amount. If type 0 is legalized before
type 1, the operations on the shift amount type use the wider type
(which are also less likely to legalize). This can be avoided by
targets specifying legalization actions on type 1 earlier than for
type 0.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353455 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-07 19:37:44 +00:00
Matt Arsenault
f2e3c26215 GlobalISel: Implement fewerElementsVector for shifts
Introduce a new function which handles instructions with multiple type
indices, but have the same number of vector elements.

Also legalize v2s16 shifts when applicable.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353432 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-07 17:38:00 +00:00
Matt Arsenault
4966488eee GlobalISel: Consolidate load/store legalization
The fewerElementsVectors implementation for load/stores
handles the scalar reduction case just as well, so drop
the redundant code in narrowScalar. This also introduces
support for narrowing irregular size breakdowns for
scalars.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353125 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-05 00:26:12 +00:00
Matt Arsenault
e3333a3a48 GlobalISel: Implement narrowScalar for select
Don't handle vector conditions.

I think this can be merged in the future with
fewerElementsVectorSelect, although this becomes slightly tricky with
a vector condition.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353122 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-05 00:13:44 +00:00
Matt Arsenault
733c08b6b3 GlobalISel: Fix not calling observer when legalizing bitcount ops
This was hiding bugs from never legalizing the source type.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353102 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-04 22:26:33 +00:00
Matt Arsenault
c1923fc6c2 GlobalISel: Implement widenScalar for G_UNMERGE_VALUES
For the scalar case only.

Also move the similar G_MERGE_VALUES handling to a separate function
and cleanup to make them look more similar.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352979 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-03 00:07:33 +00:00
Matt Arsenault
757bd101c7 GlobalISel: Implement widenScalar for G_EXTRACT vector sources
Handle the basic element extract case.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352978 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-02 23:56:00 +00:00
Matt Arsenault
87de283c8b GlobalISel: Legalization for inttoptr/ptrtoint
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352973 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-02 23:29:55 +00:00
Matt Arsenault
2a852a1e74 GlobalISel: Handle odd splits in fewerElementsVector for load/store
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352720 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-31 02:46:05 +00:00
Matt Arsenault
8927be488e GlobalISel: Implement narrowScalar for bswap
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352719 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-31 02:34:03 +00:00
Matt Arsenault
bda0adb383 GlobalISel: Don't call changingInstruction before giving up
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352718 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-31 02:22:39 +00:00
Matt Arsenault
d08f66450d GlobalISel: Allow bitcount ops to have different result type
For AMDGPU the result is always 32-bit for 64-bit inputs.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352717 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-31 02:09:57 +00:00
Matt Arsenault
b2d28d4c34 GlobalISel: Use helper function for MMO splitting
Also fix an alignment bug getMachineMemOperand. If the
tracked value is null, the offset isn't tracked so the
base alignment needs to be reduced.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352716 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-31 01:49:58 +00:00
Jessica Paquette
e2abb7ac81 [GlobalISel][AArch64] Select G_FEXP
This teaches the legalizer to handle G_FEXP in AArch64. As a result, it also
allows us to select G_FEXP.

It...

- Updates the legalizer-info tests
- Adds a test for legalizing exp
- Updates the existing fp tests to show that we can now select G_FEXP

https://reviews.llvm.org/D57483

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352692 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-30 23:46:15 +00:00
Amara Emerson
8b38d7e571 [GlobalISel][LegalizerHelper] Add some missing MI change observer calls.
No test as it's a preventative fix.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352691 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-30 23:42:46 +00:00
Jessica Paquette
5d6324274b [GlobalISel][AArch64] Add instruction selection support for @llvm.log2
This teaches GlobalISel to emit a RTLib call for @llvm.log2 when it encounters
it.

It updates the existing floating point tests to show that we don't fall back on
the intrinsic, and select the correct instructions. It also adds a legalizer
test for G_FLOG2.

https://reviews.llvm.org/D57357

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352673 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-30 21:16:04 +00:00
Jessica Paquette
d2bce7d4ae [GlobalISel][AArch64] Add instruction selection support for @llvm.sqrt
This teaches the legalizer about G_FSQRT in AArch64. Also adds a legalizer
test for G_FSQRT, a selection test for it, and updates existing floating point
tests.

https://reviews.llvm.org/D57361

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352671 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-30 21:03:52 +00:00
Matt Arsenault
e405a3bd22 GlobalISel: Implement fewerElementsVector for select
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352601 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-30 04:19:31 +00:00
Matt Arsenault
a20ea20810 GlobalISel: Use appropriate extension for legalizing select conditions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352597 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-30 02:57:43 +00:00
Matt Arsenault
00f3241eeb GlobalISel: Support narrowScalar for uneven loads
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352594 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-30 02:35:38 +00:00
Matt Arsenault
553368f2f8 GlobalISel: Handle some odd splits in fewerElementsVector
Also add some quick hacks to AMDGPU legality for the tests.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352591 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-30 02:22:13 +00:00
Matt Arsenault
c2b6aeb1f4 GlobalISel: Handle more cases for widenScalar for G_STORE
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352585 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-30 02:04:31 +00:00
Matt Arsenault
8859c398f2 GlobalISel: Fix unused variable warning in release builds
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352565 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-29 23:38:42 +00:00
Matt Arsenault
9fb9172b43 GlobalISel: Partially implement widenScalar for MERGE_VALUES
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352560 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-29 23:17:35 +00:00
Matt Arsenault
ae17beb3c1 GlobalISel: Fix narrowScalar for load/store with different mem size
This was ignoring the memory size, and producing multiple loads/stores
if the operand size was different from the memory size.

I assume this is the intent of not having an explicit G_ANYEXTLOAD
(although I think that would probably be better).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352523 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-29 18:13:02 +00:00
Jessica Paquette
42bf149c65 [GlobalISel][AArch64] Add legalization for G_FLOG
This adds support for legalizing G_FLOG into a RTLib call.

It adds a legalizer test, and updates the existing floating point tests.

https://reviews.llvm.org/D57347

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352429 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-28 21:27:23 +00:00