1. Jan 30, 2020
    • Jay Foad's avatar
    • Kazushi (Jam) Marukawa's avatar
      [VE] (conditional) branch modification & isel patterns · fef80a29
      Kazushi (Jam) Marukawa authored
      Summary:
      InstInfo for branch modification, (conditional) branch isel patterns and tests.
      
      Reviewed By: arsenm
      
      Differential Revision: https://reviews.llvm.org/D73632
      fef80a29
    • Matt Arsenault's avatar
      GlobalISel: Fix mask computation in lowerInsert · b63629a5
      Matt Arsenault authored
      This is supposed to be the high bit index, not the width. Use the
      wrapping form of getBitsSet and avoid the bitflip.
      b63629a5
    • Matt Arsenault's avatar
      AMDGPU: Directly select 16-bank LDS case of llvm.amdgcn.interp.p1.f16 · 68b102b9
      Matt Arsenault authored
      Manually select this is as a tablegen workraound. Both SelectionDAG
      and GlobalISel end up misplacing the copy to m0 when both instructions
      in the output need it. Neither considers that both output instructions
      depend on m0. I don't know of any other pattern we need to handle this
      case, so it's less effort to just workaround this for now.
      68b102b9
    • Jay Foad's avatar
      [MachineScheduler] Ignore artificial edges when forming store chains · 0d7bd343
      Jay Foad authored
      Summary:
      BaseMemOpClusterMutation::apply forms store chains by looking for
      control (i.e. non-data) dependencies from one mem op to another.
      
      In the test case, clusterNeighboringMemOps successfully clusters the
      loads, and then adds artificial edges to the loads' successors as
      described in the comment:
            // Copy successor edges from SUa to SUb. Interleaving computation
            // dependent on SUa can prevent load combining due to register reuse.
      The effect of this is that *data* dependencies from one load to a store
      are copied as *artificial* dependencies from a different load to the
      same store.
      
      Then when BaseMemOpClusterMutation::apply looks at the stores, it finds
      that some of them have a control dependency on a previous load, which
      breaks the chains and means that the stores are not all considered part
      of the same chain and won't all be clustered.
      
      The fix is to only consider non-artificial control dependencies when
      forming chains.
      
      Subscribers: MatzeB, jvesely, nhaehnle, hiraditya, javed.absar, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D71717
      0d7bd343
    • Matt Arsenault's avatar
      96352e0a
    • Elia Geretto's avatar
      [PassManagerBuilder] Remove global extension when a plugin is unloaded · ab2300bc
      Elia Geretto authored
      This commit fixes PR39321.
      
      GlobalExtensions is not guaranteed to be destroyed when optimizer plugins are unloaded. If it is indeed destroyed after a plugin is dlclose-d, the destructor of the corresponding ExtensionFn is not mapped anymore, causing a call to unmapped memory during destruction.
      
      This commit guarantees that extensions coming from external plugins are removed from GlobalExtensions when the plugin is unloaded if GlobalExtensions has not been destroyed yet.
      
      Differential Revision: https://reviews.llvm.org/D71959
      ab2300bc
    • Connor Abbott's avatar
      AMDGPU: Fix handling of infinite loops in fragment shaders · 87d98c14
      Connor Abbott authored
      Summary:
      Due to the fact that kill is just a normal intrinsic, even though it's
      supposed to terminate the thread, we can end up with provably infinite
      loops that are actually supposed to end successfully. The
      AMDGPUUnifyDivergentExitNodes pass breaks up these loops, but because
      there's no obvious place to make the loop branch to, it just makes it
      return immediately, which skips the exports that are supposed to happen
      at the end and hangs the GPU if all the threads end up being killed.
      
      While it would be nice if the fact that kill terminates the thread were
      modeled in the IR, I think that the structurizer as-is would make a mess if we
      did that when the kill is inside control flow. For now, we just add a null
      export at the end to make sure that it always exports something, which fixes
      the immediate problem without penalizing the more common case. This means that
      we sometimes do two "done" exports when only some of the threads enter the
      discard loop, but from tests the hardware seems ok with that.
      
      This fixes dEQP-VK.graphicsfuzz.while-inside-switch with radv.
      
      Reviewers: arsenm, nhaehnle
      
      Subscribers: kzhuravl, jvesely, wdng, yaxunl, dstuttard, tpr, t-tye, hiraditya, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D70781
      87d98c14
    • Matt Arsenault's avatar
      AMDGPU/GlobalISel: Look through copies for source modifiers · 94e8ef4d
      Matt Arsenault authored
      When all VOP instructions are legalized to VGPRs, any SGPR source
      modifiers will have a copy in the way.
      94e8ef4d
    • Stanislav Mekhanoshin's avatar
      [AMDGPU] override isHighLatencyDef · c2ad7ee1
      Stanislav Mekhanoshin authored
      SIMachineScheduler uses isHighLatencyInstruction with the same
      sematincs, but TargetInstrInfo has virtual isHighLatencyDef
      method, so override it instead.
      
      Added FLAT to the list of high latency opcodes and a check for
      mayLoad since stores are not technically high latency in terms
      of data dependency.
      
      This change did not produce any visible impact on our tests.
      
      Differential Revision: https://reviews.llvm.org/D73582
      c2ad7ee1
  2. Jan 29, 2020
    • Matt Arsenault's avatar
      GlobalISel: Assert on invalid bitcast in MIRBuilder · f717483a
      Matt Arsenault authored
      The other casts validate, so this should too.
      f717483a
    • Matt Arsenault's avatar
      AMDGPU/GlobalISel: Rewrite fadd select tests · 752e2e24
      Matt Arsenault authored
      Convert to the style most others use with one test instruction per
      function, and use an implicit use to ensure the result register class
      is constrained.
      
      Change-Id: I6109148b0e3c80aa5535796a37abca583c19a936
      752e2e24
    • Benjamin Kramer's avatar
      [clang-tidy] Initialize token before handing it to the lexer · 01213f90
      Benjamin Kramer authored
      Found by msan.
      01213f90
    • Simon Pilgrim's avatar
      79748add
    • Hans Wennborg's avatar
      31e07692
    • Matt Arsenault's avatar
      LLT: Add changeNumElements · 24ab761a
      Matt Arsenault authored
      This is the element analog of changeElementType/changeElementSize
      24ab761a
    • LLVM GN Syncbot's avatar
      [gn build] Port 9a08a3fa · df8f2774
      LLVM GN Syncbot authored
      df8f2774
    • Connor Abbott's avatar
      Revert "AMDGPU: Fix handling of infinite loops in fragment shaders" · 08b205bb
      Connor Abbott authored
      This reverts commit 0994c485.
      08b205bb
    • Connor Abbott's avatar
      13ab22ab
    • Adam Balogh's avatar
      [Analyzer] Split container modeling from iterator modeling · 9a08a3fa
      Adam Balogh authored
      Iterator modeling depends on container modeling,
      but not vice versa. This enables the possibility
      to arrange these two modeling checkers into
      separate layers.
      
      There are several advantages for doing this: the
      first one is that this way we can keep the
      respective modeling checkers moderately simple
      and small. Furthermore, this enables creation of
      checkers on container operations which only
      depend on the container modeling. Thus iterator
      modeling can be disabled together with the
      iterator checkers if they are not needed.
      
      Since many container operations also affect
      iterators, container modeling also uses the
      iterator library: it creates iterator positions
      upon calling the `begin()` or `end()` method of
      a containter (but propagation of the abstract
      position is left to the iterator modeling),
      shifts or invalidates iterators according to the
      rules upon calling a container modifier and
      rebinds the iterator to a new container upon
      `std::move()`.
      
      Iterator modeling propagates the abstract
      iterator position, handles the relations between
      iterator positions and models iterator
      operations such as increments and decrements.
      
      Differential Revision: https://reviews.llvm.org/D73547
      9a08a3fa
    • Whitney Tsang's avatar
      [LoopFusion] Move instructions from FC1.Preheader to FC0.Preheader when · da58e68f
      Whitney Tsang authored
      proven safe.
      
      Summary:
      Currently LoopFusion give up when the second loop nest preheader is
      not empty. For example:
      
      for (int i = 0; i < 100; ++i) {}
      x+=1;
      for (int i = 0; i < 100; ++i) {}
      The above example should be safe to fuse.
      This PR moves instructions in FC1 preheader (e.g. x+=1; ) to
      FC0 preheader, which then LoopFusion is able to fuse them.
      Reviewer: kbarton, Meinersbur, jdoerfert, dmgreen, fhahn, hfinkel,
      bmahjour, etiotto
      Reviewed By: jdoerfert
      Subscribers: hiraditya, llvm-commits
      Tag: LLVM
      Differential Revision: https://reviews.llvm.org/D71821
      da58e68f
    • Kazushi (Jam) Marukawa's avatar
      [VE] udiv/sdiv/urem/srem/mul isel patterns · 0bec0e71
      Kazushi (Jam) Marukawa authored
      Summary:
      udiv/sdiv/urem/srem/mul integer isel patterns and tests.
      Pretend for now that integer division were always cheap in HW.
      
      Reviewed By: arsenm
      
      Differential Revision: https://reviews.llvm.org/D73623
      0bec0e71
    • Guillaume Chatelet's avatar
      [libc] Fix benchmarks CMakeLists.txt · c2dcdf95
      Guillaume Chatelet authored
      Summary:
      This is a follow up on https://reviews.llvm.org/rGaba80d0734d1#886881.
      `target_link_options` requires CMake>=3.13.
      
      Reviewers: abrachet
      
      Subscribers: mgorny, MaskRay, tschuett, libc-commits
      
      Tags: #libc-project
      
      Differential Revision: https://reviews.llvm.org/D73452
      c2dcdf95
    • Nicolas Vasilache's avatar
      [mlir][Linalg] Introduce folding patterns to remove certain MemRefCastOp · ea1e3369
      Nicolas Vasilache authored
      Summary:
      Canonicalization and folding patterns in StandardOps may interfere with the needs
      of Linalg. This revision introduces specific foldings for dynamic memrefs that can
      be proven to be static.
      
      Very concretely:
      
      Determines whether it is possible to fold it away in the parent Linalg op:
      
      ```mlir
        %1 = memref_cast %0 : memref<8x16xf32> to memref<?x?xf32>
        %2 = linalg.slice %1 ... : memref<?x?xf32> ...
        // or
        %1 = memref_cast %0 : memref<8x16xf32, affine_map<(i, j)->(16 * i + j)>>
               to memref<?x?xf32>
        linalg.generic(%1 ...) : memref<?x?xf32> ...
      ```
      
      into
      
      ```mlir
        %2 = linalg.slice %0 ... : memref<8x16xf32> ...
        // or
        linalg.generic(%0 ... : memref<8x16xf32, affine_map<(i, j)->(16 * i + j)>>
      ```
      
      Reviewers: ftynse, aartbik, jsetoain, tetuante, asaadaldien
      
      Subscribers: mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, arpith-jacob, mgester, lucyrfox, liufengdb, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D73565
      ea1e3369
    • Matt Arsenault's avatar
      AMDGPU/GlobalISel: Manually select scalar f64 G_FNEG · 02adfb51
      Matt Arsenault authored
      This should be no problem to support with a pattern, but it turns out
      there are just too many yaks to shave. The main problem is in the DAG
      emitter, which I have no desire to sink effort into fixing.
      
      If we had a bit to disable patterns in the DAG importer, fixing the
      GlobalISelEmitter is more manageable.
      02adfb51
    • Matt Arsenault's avatar
      Analysis: Add max recursison to isDereferenceableAndAlignedPointer · a9af1dc3
      Matt Arsenault authored
      Fixes stack overflow in test/CodeGen/X86/large-gep-chain.ll when store
      lowering starts adding dereferenceable flags.
      a9af1dc3
    • Matt Arsenault's avatar
      GlobalISel: Lower G_WRITE_REGISTER · c5c1bb33
      Matt Arsenault authored
      c5c1bb33
    • Mikael Holmén's avatar
      2103e08b
    • Connor Abbott's avatar
      AMDGPU: Fix AMDGPUUnifyDivergentExitNodes with no normal returns · 323bfde2
      Connor Abbott authored
      Summary:
      The code was assuming in a few places that if there was only one exit
      from the function that it was a normal return, which is invalid. It
      could be an infinite loop, in which case we still need to insert the
      usual fake edge so that the null export happens. This fixes shaders that
      end with an infinite loop that discards.
      
      Reviewers: arsenm, nhaehnle, critson
      
      Subscribers: kzhuravl, jvesely, wdng, yaxunl, dstuttard, tpr, t-tye, hiraditya, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D71192
      323bfde2
    • Connor Abbott's avatar
      AMDGPU: Fix handling of infinite loops in fragment shaders · 0994c485
      Connor Abbott authored
      Summary:
      Due to the fact that kill is just a normal intrinsic, even though it's
      supposed to terminate the thread, we can end up with provably infinite
      loops that are actually supposed to end successfully. The
      AMDGPUUnifyDivergentExitNodes pass breaks up these loops, but because
      there's no obvious place to make the loop branch to, it just makes it
      return immediately, which skips the exports that are supposed to happen
      at the end and hangs the GPU if all the threads end up being killed.
      
      While it would be nice if the fact that kill terminates the thread were
      modeled in the IR, I think that the structurizer as-is would make a mess if we
      did that when the kill is inside control flow. For now, we just add a null
      export at the end to make sure that it always exports something, which fixes
      the immediate problem without penalizing the more common case. This means that
      we sometimes do two "done" exports when only some of the threads enter the
      discard loop, but from tests the hardware seems ok with that.
      
      This fixes dEQP-VK.graphicsfuzz.while-inside-switch with radv.
      
      Reviewers: arsenm, nhaehnle
      
      Subscribers: kzhuravl, jvesely, wdng, yaxunl, dstuttard, tpr, t-tye, hiraditya, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D70781
      0994c485
    • Haojian Wu's avatar
      [clangd] Remove the temporary alias for clangd::DiagnosticConsumer. · fce8983a
      Haojian Wu authored
      Reviewers: sammccall
      
      Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits
      
      Tags: #clang
      
      Differential Revision: https://reviews.llvm.org/D73619
      fce8983a
    • Sanjay Patel's avatar
      [InstCombine] canonicalize splat shuffle after cmp · 87f6314f
      Sanjay Patel authored
      cmp (splat V1, M), SplatC --> splat (cmp V1, SplatC'), M
      
      As discussed in PR44588:
      https://bugs.llvm.org/show_bug.cgi?id=44588
      ...we try harder to push shuffles after binops than after compares.
      
      This patch handles the special (but presumably most common case) of
      splat shuffles. If both operands are splats, then we can do the
      comparison on the non-splat inputs followed by splat of the compare.
      That should take care of the regression noted in D73411.
      
      There's another potential fold requested in PR37463 to scalarize the
      compare, but that's another patch (and it's not clear if we can do
      that without the ability to undo it later):
      https://bugs.llvm.org/show_bug.cgi?id=37463
      
      Differential Revision: https://reviews.llvm.org/D73575
      87f6314f
    • Sanne Wouda's avatar
      [AArch64] Add IR intrinsics for sq(r)dmulh_lane(q) · 2939fc13
      Sanne Wouda authored
      Summary:
      Currently, sqdmulh_lane and friends from the ACLE (implemented in arm_neon.h),
      are represented in LLVM IR as a (by vector) sqdmulh and a vector of (repeated)
      indices, like so:
      
         %shuffle = shufflevector <4 x i16> %v, <4 x i16> undef, <4 x i32> <i32 3, i32 3, i32 3, i32 3>
         %vqdmulh2.i = tail call <4 x i16> @llvm.aarch64.neon.sqdmulh.v4i16(<4 x i16> %a, <4 x i16> %shuffle)
      
      When %v's values are known, the shufflevector is optimized away and we are no
      longer able to select the lane variant of sqdmulh in the backend.
      
      This defeats a (hand-coded) optimization that packs several constants into a
      single vector and uses the lane intrinsics to reduce register pressure and
      trade-off materialising several constants for a single vector load from the
      constant pool, like so:
      
         int16x8_t v = {2,3,4,5,6,7,8,9};
         a = vqdmulh_laneq_s16(a, v, 0);
         b = vqdmulh_laneq_s16(b, v, 1);
         c = vqdmulh_laneq_s16(c, v, 2);
         d = vqdmulh_laneq_s16(d, v, 3);
         [...]
      
      In one microbenchmark from libjpeg-turbo this accounts for a 2.5% to 4%
      performance difference.
      
      We could teach the compiler to recover the lane variants, but this would likely
      require its own pass.  (Alternatively, "volatile" could be used on the constants
      vector, but this is a bit ugly.)
      
      This patch instead implements the following LLVM IR intrinsics for AArch64 to
      maintain the original structure through IR optmization and into instruction
      selection:
      - sqdmulh_lane
      - sqdmulh_laneq
      - sqrdmulh_lane
      - sqrdmulh_laneq.
      
      These 'lane' variants need an additional register class.  The second argument
      must be in the lower half of the 64-bit NEON register file, but only when
      operating on i16 elements.
      
      Note that the existing patterns for shufflevector and sqdmulh into sqdmulh_lane
      (etc.) remain, so code that does not rely on NEON intrinsics to generate these
      instructions is not affected.
      
      This patch also changes clang to emit these IR intrinsics for the corresponding
      NEON intrinsics (AArch64 only).
      
      Reviewers: SjoerdMeijer, dmgreen, t.p.northover, rovka, rengolin, efriedma
      
      Reviewed By: efriedma
      
      Subscribers: kristof.beyls, hiraditya, jdoerfert, cfe-commits, llvm-commits
      
      Tags: #clang, #llvm
      
      Differential Revision: https://reviews.llvm.org/D71469
      2939fc13
    • Sjoerd Meijer's avatar
      [MVE][MC] evaluateBranch: add missing MVE opcode · f719b0ba
      Sjoerd Meijer authored
      This adds some missing MVE opcodes to evaluateBranch, which results in
      llvm-objdump being able to print the PC relative branch target as an
      annotation.
      
      Differential Revision: https://reviews.llvm.org/D73553
      f719b0ba
    • Kazushi (Jam) Marukawa's avatar
      [VE] Isel patterns for fp32/64 and i32/64 conversion · 6b587ee2
      Kazushi (Jam) Marukawa authored
      Summary:
      fp32/64 <> signed/unsigned i32/64 conversion isel patterns and tests
      
      (This patch depends on `fsub` implemented by https://reviews.llvm.org/D73540 )
      
      Reviewers: arsenm, craig.topper, rengolin, k-ishizaka
      
      Reviewed By: arsenm
      
      Subscribers: merge_guards_bot, wdng, hiraditya, llvm-commits
      
      Tags: #ve, #llvm
      
      Differential Revision: https://reviews.llvm.org/D73544
      6b587ee2
    • Sanne Wouda's avatar
      Regenerate aarch64-neon-2velem.c CHECK lines · cbc45e4e
      Sanne Wouda authored
      cbc45e4e
    • Sanne Wouda's avatar
      Fix clang test build · 4ec2a267
      Sanne Wouda authored
      4ec2a267
    • Karasev Nikita's avatar
      Add TagDecl AST matcher · d5dfd135
      Karasev Nikita authored
      d5dfd135
    • Georgii Rymar's avatar
      [yaml2obj][obj2yaml] - Add lost test cases. · e6b55cbc
      Georgii Rymar authored
      It is a part of https://reviews.llvm.org/D71872 which
      was lost somehow during relanding after being reverted:
      
      https://reviews.llvm.org/rG7570d387c21935b58afa67cb9ee17250e38721fa
      e6b55cbc
    • Martin Probst's avatar
      clang-format: insert trailing commas into containers. · a324fcf1
      Martin Probst authored
      Summary:
      This change adds an option to insert trailing commas into container
      literals. For example, in JavaScript:
      
          const x = [
            a,
            b,
             ^~~~~ inserted if missing.
          ]
      
      This is implemented as a seperate post-processing pass after formatting
      (because formatting might change whether the container literal does or
      does not wrap). This keeps the code relatively simple and orthogonal,
      though it has the notable drawback that the newly inserted comma is not
      taken into account for formatting decisions (e.g. it might exceed the 80
      char limit). To avoid exceeding the ColumnLimit, a comma is only
      inserted if it fits into the limit.
      
      Trailing comma insertion conceptually conflicts with argument
      bin-packing: inserting a comma disables bin-packing, so we cannot do
      both. clang-format rejects FormatStyle configurations that do both with
      this change.
      
      Reviewers: krasimir, MyDeveloperDay
      
      Subscribers: cfe-commits
      
      Tags: #clang
      a324fcf1