1. Nov 30, 2023
    • Shengchen Kan's avatar
      [X86][tablgen] Auto-gen broadcast tables (#73654) · a4e1aa25
      Shengchen Kan authored
      1. Add TB_BCAST_SH for FP16
      2. Auto-gen 4 broadcast tables BroadcastTable[1-4]
      
      issue: https://github.com/llvm/llvm-project/issues/66360
      a4e1aa25
    • David Spickett's avatar
      [llvm][AArch64] Preserve regmask when expanding the BLR_BTI pseudo instruction (#73927) · 99d48591
      David Spickett authored
      Fixes #73787
      
      Not doing so lead to us making use of a register after the call, which
      has been clobbered by the call.
      
      Added an MIR test that runs only the pseudo expansion pass.
      99d48591
    • frgossen's avatar
      Fix bazel build (#73942) · 402591a4
      frgossen authored
      402591a4
    • Hui's avatar
      [libc++] Workaround linker errors in floating-point atomic tests (#73398) · 6677f029
      Hui authored
      We now add -latomic whenever we detect that it's supported on the platform,
      and we mark the tests as UNSUPPORTED on platforms where non-lockfree
      atomics are not supported.
      6677f029
    • Lucas Duarte Prates's avatar
      [AArch64] Fix predicates for FEAT_CPA's SVE-specific instructions (#73923) · 78237b70
      Lucas Duarte Prates authored
      Following up on #73777, this fixes the predicate for the SVE-specific
      FEAT_CPA instructions to require SVE instead of SVE or SME. These
      instructions should not be availabe if only SME is enabled.
      78237b70
    • Adam Paszke's avatar
      [MLIR][CUDA] Update export macros in CudaRuntimeWrappers (#73932) · 1c2a0768
      Adam Paszke authored
      This fixes a few issues present in the current version:
      1) The macro doesn't enforce the default visibility on exported
         functions, causing compilation to fail when using
         `-fvisibility=hidden`
      2) Not all functions are exported
      3) Sometimes the macro ended up weirdly interleaved with `extern "C"`
         declarations
      1c2a0768
    • Nikita Popov's avatar
      [InstCombine] Add KnownBits consistency assertion behind option (NFC) · 10b44fb6
      Nikita Popov authored
      I'm occasionally using this to find cases where computeKnownBits()
      and SimplifyDemandedBits() went out of sync.
      
      This option is not enabled by default (even under EXPENSIVE_CHECKS)
      because it has a number of known failures in our tests. The reason
      for this failures is that computeKnownBits() performs recursive
      queries using the original context instruction, while
      SimplifyDemandedBits() uses the current instruction. This is
      something we can improve, but using the original context wouldn't
      always be safe in this context (when non-speculatable instructions
      are involved).
      10b44fb6
    • Jeremy Morse's avatar
      [DebugInfo] Set all dbg.value intrinsics to be tail-calls (#73661) · cd02e4b8
      Jeremy Morse authored
      This change has no meaningful effect on the compiler, although it has a
      functional effect of dbg.value intrinsics being printed differently. The
      tail-call flag is meaningless for debug-intrinsics and doesn't serve a
      purpose, it's just extra baggage that dbg.values are built on top of.
      Some facilities create debug-intrinsics with the flag, others don't.
      However, the RemoveDIs project to represent debug-info without
      intrinsics doesn't have a corresponding flag, which can cause spurious
      test differences.
      
      Specifically: we can convert a dbg.value to a DPValue, run an
      optimisation pass, then convert the DPValue back to dbg.value form.
      Right now, we always set the "tail" flag when converting it back. This
      causes the auto-update-tests script to fail sometimes because in one
      mode (dbg.value) intrinsics might not have a tail flag, but in the other
      they do have a tail flag. Consistently picking one or the other in the
      conversion routine doesn't help, because the rest of LLVM is
      inconsistent about it anyway.
      
      Thus: whenever we make a dbg.value intrinsic, create it as a tail call,
      so that we get consistent output behaviours no matter which debug-info
      mode we're in, DPValue or dbg.value. No tests fail as a result of this
      patch because the extra 'tail' generated in numerous tests is
      automatically ignored by FileCheck as being leading-rubbish before the
      CHECK match.
      cd02e4b8
    • leecheechen's avatar
      [LoongArch] Add some binary IR instructions testcases for LSX (#73929) · 29a0f3ec
      leecheechen authored
      The IR instructions include:
      - Binary Operations: add fadd sub fsub mul fmul udiv sdiv fdiv
      - Bitwise Binary Operations: shl lshr ashr
      29a0f3ec
    • Matt Arsenault's avatar
      MachineVerifier: Reject extra non-register operands on instructions (#73758) · c44dca15
      Matt Arsenault authored
      We were allowing extra immediate arguments, and only bothering to check
      if registers were implicit or not.
      
      Also consolidate extra operand checks in verifier, to make this
      testable. We had 3 different places checking if you were trying to build
      an instruction with more operands than allowed by the definition. We had
      an assertion in addOperand, a direct check in the MIRParser to avoid the
      assertion, and the machine verifier checks. Remove the assert and parser
      check so the verifier can provide a consistent verification experience,
      which will also handle instructions modified in place.
      c44dca15
    • Nikita Popov's avatar
      [InstCombine] Require non-demanded known bits to be accurate (NFC) · 2031e722
      Nikita Popov authored
      In practice this is already true, and having this as an explicit
      guarantee is useful for #72912. I don't think there is any good
      reason why we would want to produce incorrect KnownBits results
      for non-demanded bits.
      2031e722
    • Nikita Popov's avatar
      [InstCombine] Use analyzeKnownBitsFromAndXorOr() in multi-use demanded bits · 062058ef
      Nikita Popov authored
      We were using this helper in single-use demanded bits but not
      multi-use demanded bits.
      
      This fixes an assertion failure when asserting consistency between
      computeKnownBits() and SimplifyDemandedBits().
      062058ef
    • Antonio Frighetto's avatar
      [InstCombine] Switch to use FileCheck as UTC was favoured (NFC) · 3f6a8e9b
      Antonio Frighetto authored
      FileCheck was previously missing while moving to UTC, as part of
      regenerating other tests within InstCombine.
      3f6a8e9b
    • Nikita Popov's avatar
      [ValueTracking] Switch analyzeKnownBitsFromAndXorOr() to use SimplifyQuery (NFC) · 1566380e
      Nikita Popov authored
      It already used it internally, make the public API use it as well.
      1566380e
    • Jeremy Morse's avatar
      [DebugInfo][RemoveDIs] Have LICM insert at iterator positions (#73671) · 5ba5211a
      Jeremy Morse authored
      Because we're storing some extra debug-info information in the iterator
      class, we need to insert new LICM-created stores using such iterators.
      Switch LICM to storing iterators instead of pointers when it promotes
      variables in loops, add a test for the desired behaviour, and enable
      RemoveDIs instrumentation on a variety of other LICM tests for good
      measure.
      
      (This would appear to be the only pass in LLVM that needs to store
      iterators on the heap).
      5ba5211a
    • Nikita Popov's avatar
      [InstCombine] Use pointer alignment in SimplifyDemandedBits · b8a5a015
      Nikita Popov authored
      For parity with computeKnownBits(). This came up when adding a
      consistency assertion.
      b8a5a015
    • Guillaume Chatelet's avatar
      [libc] Add more functions in CPP/bit.h (#73814) · b703bd82
      Guillaume Chatelet authored
      Once this is submitted we can remove `include/__support/bit.h` that
      duplicates some of this functionality.
      b703bd82
    • Jeremy Morse's avatar
      [DebugInfo][RemoveDIs] Emulate inserting insts in dbg.value sequences (#73350) · 2ec0283c
      Jeremy Morse authored
      Here's a problem for the RemoveDIs project to make debug-info not be
      stored in instructions -- in the following sequence:
          dbg.value(foo
          %bar = add i32 ...
          dbg.value(baz
      It's possible for rare passes (only CodeGenPrepare) to remove the add
      instruction, and then re-insert it back in the same place. When
      debug-info is stored in instructions and there's a total order on "when"
      things happen this is easy, but by moving that information out of the
      instruction stream we start having to do manual maintenance.
      
      This patch adds some utilities for re-inserting an instruction into a
      sequence of DPValue objects. Someday we hope to design this away, but
      for now it's necessary to support all the things you can do with
      dbg.values. The two unit tests show how DPValues get shuffled around
      using the relevant function calls. A follow-up patch adds
      instrumentation to CodeGenPrepare.
      2ec0283c
    • Guillaume Chatelet's avatar
    • Mariya Podchishchaeva's avatar
      [clang] Fix sanitizer bot failure after 14ca8d44 (#73928) · b9b37ea9
      Mariya Podchishchaeva authored
      Initialize field so there is no use-of-uninitialized-value warning.
      b9b37ea9
    • Rik Huijzer's avatar
      [mlir][vector] Fix a `target-rank=0` unrolling (#73365) · c84061fd
      Rik Huijzer authored
      Fixes https://github.com/llvm/llvm-project/issues/64269.
      
      With this patch, calling `mlir-opt "-convert-vector-to-scf=full-unroll
      target-rank=0"` on
      ```mlir
      func.func @main(%vec : vector<2xi32>) {
        %alloc = memref.alloc() : memref<4xi32>
        %c0 = arith.constant 0 : index
        vector.transfer_write %vec, %alloc[%c0] : vector<2xi32>, memref<4xi32>
        return
      }
      ```
      will result in
      ```mlir
      module {
        func.func @main(%arg0: vector<2xi32>) {
          %c0 = arith.constant 0 : index
          %c1 = arith.constant 1 : index
          %alloc = memref.alloc() : memref<4xi32>
          %0 = vector.extract %arg0[0] : i32 from vector<2xi32>
          %1 = vector.broadcast %0 : i32 to vector<i32>
          vector.transfer_write %1, %alloc[%c0] : vector<i32>, memref<4xi32>
          %2 = vector.extract %arg0[1] : i32 from vector<2xi32>
          %3 = vector.broadcast %2 : i32 to vector<i32>
          vector.transfer_write %3, %alloc[%c1] : vector<i32>, memref<4xi32>
          return
        }
      }
      ```
      
      I've also tried to proactively find other `target-rank=0` bugs, but
      couldn't find any. `options.targetRank` is only used 8 times throughout
      the `mlir` folder, all inside `VectorToSCF.cpp`. None of the other uses
      look like they could cause a crash. I've also tried
      
      ```mlir
      func.func @main(%vec : vector<2xi32>) -> vector<2xi32> {
        %alloc = memref.alloc() : memref<4xindex>
        %c0 = arith.constant 0 : index
        %out = vector.transfer_read %alloc[%c0], %c0 : memref<4xindex>, vector<2xi32>
        return %out : vector<2xi32>
      }
      ```
      with `"--convert-vector-to-scf=full-unroll target-rank=0"` and that also
      didn't crash. (Maybe obvious. I have to admit that I'm not very familiar
      with these ops.)
      c84061fd
    • Jeremy Morse's avatar
      [DebugInfo][RemoveDIs] Have getInsertionPtAfterDef return an iterator (#73149) · 2425e294
      Jeremy Morse authored
      Part of the "RemoveDIs" project to remove debug intrinsics requires
      passing block-positions around in iterators rather than as instruction
      pointers, allowing some debug-info to reside in BasicBlock::iterator.
      This means getInsertionPointAfterDef has to return an iterator, and as
      it can return no-instruction that means returning an optional iterator.
      
      This patch changes the signature for getInsertionPtAfterDef and then
      patches up the various places that use it to handle the different type.
      This would overall be an NFC patch, however in
      InstCombinerImpl::freezeOtherUses I've started skipping any debug
      intrinsics at the returned insert-position. This should not have any
      _meaningful_ effect on the compiler output: at worst it means variable
      assignments that are skipped will now cover the freeze instruction and
      anything inserted before it, which should be inconsequential.
      
      Sadly: this makes the function signature ugly. This is probably the
      ugliest piece of fallout for the "RemoveDIs" work, but it serves the
      overall purpose of improving compile times and not allowing `-g` to
      affect compiler output, so should be worthwhile in the end.
      2425e294
    • David Green's avatar
    • Paul Walker's avatar
      [LLVM][SVE] Honour calling convention when using SVE for fixed length vectors. (#70847) · 4db451a8
      Paul Walker authored
      NOTE: I'm not sure how many of the corner cases are part of the
      documented ABI but that shouldn't matter because my goal is for
      `-msve-vector-bits` to have no affect on the way arguments and returns
      are processed.
      4db451a8
    • Antonio Frighetto's avatar
      00a10efd
    • Simon Pilgrim's avatar
    • Simon Pilgrim's avatar
      [X86] Add fcopysign vector test coverage · e653e030
      Simon Pilgrim authored
      e653e030
    • Jean Perier's avatar
      [flang] Remove useless ConvertExpr.h includes in Optimizer · 4793bce7
      Jean Perier authored
      Added by mistake in https://github.com/llvm/llvm-project/pull/73658.
      Not needed and breaks shared library builds.
      4793bce7
    • Momchil Velikov's avatar
    • Michael Buch's avatar
      [clang][DebugInfo][test] Remove unchecked member variable in debug-info-static-inline-member · c80b91bc
      Michael Buch authored
      The check for this was removed in
      https://github.com/llvm/llvm-project/pull/72974
      
      This patch removes the member from the source itself since
      it was confusing FileCheck
      c80b91bc
    • Antonio Frighetto's avatar
      [InstCombine] Handle equality comparison when flooring by constant 2 · 7d5f79f1
      Antonio Frighetto authored
      Support `icmp eq` when reducing signed divisions by power of 2 to
      arithmetic shift right, as `icmp ugt` may have been canonicalized
      into `icmp eq` by the time additions are folded into `ashr`.
      
      Fixes: https://github.com/llvm/llvm-project/issues/73622.
      
      Proof: https://alive2.llvm.org/ce/z/8-eUdb.
      7d5f79f1
    • Shengchen Kan's avatar
      [X86][NFC] Refine code in X86FoldTablesEmitter.cpp · e78a45dd
      Shengchen Kan authored
      Split NFC in #73654 into a seperate commit.
      e78a45dd
    • Michael Buch's avatar
      [clang][DebugInfo] Improve heuristic to determine whether to evaluate a static... · 53a24c33
      Michael Buch authored
      [clang][DebugInfo] Improve heuristic to determine whether to evaluate a static variable's initializer (#72974)
      
      This patch extracts the logic to evaluate a C++ static data-member's
      constant initializer. This logic will be re-used in an upcoming patch.
      
      It also makes the check for whether we are dealing with a constant
      initializer more robust/idiomatic, which revealed a bug in the
      `debug-info-static-inline-member` test (which existed since its
      introduction in https://github.com/llvm/llvm-project/pull/71780)
      
      **Test changes**
      
      * `debug-info-static-member.cpp`:
        * We added the check for `const_b` as part of the
          patch series in `638a8393`.
      The check for `isUsableAsConstantExpression` added in the current patch
      doesn't support constant inline floats (since they are neither constexpr
      nor
          integrals). This isn't a regression since before said patch series
          we wouldn't ever emit the definition for `const_b` anyway. Now
      we just don't do it for `inline const float`s. This is consistent with
          GCC's behaviour starting with C++11.
      
      * `debug-info-static-inline-member`:
        * This was just a bug which is now fixed. We shouldn't emit
          a `DW_AT_const_value` for a non-const static.
      53a24c33
    • Serge Pavlov's avatar
      [clang] Use current rounding mode for float inc/dec (#73770) · e620035a
      Serge Pavlov authored
      Increment and decrement are equivalent to adding or subtracting 1. For
      the floating-point values these operations depend on the current
      rounding mode. Teach constant evaluator to perform ++ and -- according
      to the current floating-point environment.
      
      Pull request: https://github.com/llvm/llvm-project/pull/73770
      e620035a
    • Kohei Yamaguchi's avatar
      [mlir][docs] Add missing .md into Transform and Passes docs(NFC) (#73916) · 0817efc4
      Kohei Yamaguchi authored
      Fix broken docs for MeshDialect's pass and Transform dialect's loop
      extension.
      0817efc4
    • Benjamin Maxwell's avatar
      [mlir][ArmSME] Switch to an attribute-based tile allocation scheme (#73253) · eaff02f2
      Benjamin Maxwell authored
      This reworks the ArmSME dialect to use attributes for tile allocation.
      This has a number of advantages and corrects some issues with the
      previous approach:
      
      * Tile allocation can now be done ASAP (i.e. immediately after
      `-convert-vector-to-arm-sme`)
      * SSA form for control flow is now supported (e.g.`scf.for` loops that
      yield tiles)
      * ArmSME ops can be converted to intrinsics very late (i.e. after
      lowering to control flow)
       * Tests are simplified by removing constants and casts
      * Avoids correctness issues with representing LLVM `immargs` as MLIR
      values
      - The tile ID on the SME intrinsics is an `immarg` (so is required to be
      a compile-time constant), `immargs` should be mapped to MLIR attributes
      (this is already the case for intrinsics in the LLVM dialect)
      - Using MLIR values for `immargs` can lead to invalid LLVM IR being
      generated (and passes such as -cse making incorrect optimizations)
      
      As part of this patch we bid farewell to the following operations:
      
      ```mlir
      arm_sme.get_tile_id : i32
      arm_sme.cast_tile_to_vector : i32 to vector<[4]x[4]xi32>
      arm_sme.cast_vector_to_tile : vector<[4]x[4]xi32> to i32
      ```
      
      These are now replaced with:
      ```mlir
      // Allocates a new tile with (indeterminate) state:
      arm_sme.get_tile : vector<[4]x[4]xi32>
      // A placeholder operation for lowering ArmSME ops to intrinsics:
      arm_sme.materialize_ssa_tile : vector<[4]x[4]xi32>
      ```
      
      The new tile allocation works by operations implementing the
      `ArmSMETileOpInterface`. This interface says that an operation needs to
      be assigned a tile ID, and may conditionally allocate a new SME tile.
      
      Operations allocate a new tile by implementing...
      ```c++
      std::optional<arm_sme::ArmSMETileType> getAllocatedTileType()
      ```
      ...and returning what type of tile the op allocates (ZAB, ZAH, etc).
      
      Operations that don't allocate a tile return `std::nullopt` (which is
      the default behaviour).
      
      Currently the following ops are defined as allocating:
      ```mlir
      arm_sme.get_tile
      arm_sme.zero
      arm_sme.tile_load
      arm_sme.outerproduct // (if no accumulator is specified)
      ```
      
      Allocating operations become the roots for the tile allocation pass,
      which currently just (naively) assigns all transitive uses of a root
      operation the same tile ID. However, this is enough to handle current
      use cases.
      
      Once tile IDs have been allocated subsequent rewrites can forward the
      tile IDs to any newly created operations.
      eaff02f2
    • Jonas Paulsson's avatar
    • Lucas Duarte Prates's avatar
      [AArch64] Assembly support for the Checked Pointer Arithmetic Extension (#73777) · eef8e1d2
      Lucas Duarte Prates authored
      This introduces assembly support for the Checked Pointer Arithmetic
      Extension (FEAT_CPA), annouced as part of the Armv9.5-A architecture
      version.
      
      The changes include:
      * New subtarget feature for FEAT_CPA
      * New scalar instruction for pointer arithmetic
        * ADDPT, SUBPT, MADDPT, and MSUBPT
      * New SVE instructions for pointer arithmetic
        * ADDPT (vectors, predicated), ADDPT (vectors, unpredicated)
        * SUBPT (vectors, predicated), SUBPT (vectors, unpredicated)
        * MADPT and MLAPT
      * New ID_AA64ISAR3_EL1 system register
      
      Mode details about the extension can be found at:
      * https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/arm-a-profile-architecture-developments-2023
      * https://developer.arm.com/documentation/ddi0602/2023-09/
      
      
      
      Co-authored-by: default avatarRodolfo Wottrich <rodolfo.wottrich@arm.com>
      eef8e1d2
    • Simon Pilgrim's avatar
    • Simon Pilgrim's avatar