1. Jan 31, 2024
    • Cullen Rhodes's avatar
      [mlir][ArmSME] Support 2-way widening outer products (#78975) · 95ef8e38
      Cullen Rhodes authored
      This patch introduces support for 2-way widening outer products. This
      enables the fusion of 2 'arm_sme.outerproduct' operations that are
      chained via the accumulator into a 2-way widening outer product
      operation.
      
      Changes:
      
      - Add 'llvm.aarch64.sme.[us]mop[as].za32' intrinsics for 2-way variants.
        These map to instruction variants added in SME2 and use different
        intrinsics. Intrinsics are already implemented for widening variants
        from SME1.
      - Adds the following operations:
        - fmopa_2way, fmops_2way
        - smopa_2way, smops_2way
        - umopa_2way, umops_2way
      - Implements conversions for the above ops to intrinsics in
      ArmSMEToLLVM.
      - Adds a pass 'arm-sme-outer-product-fusion'  that fuses
        'arm_sme.outerproduct' operations.
      
      For a detailed description of these operations see the
      'arm_sme.fmopa_2way' description.
      
      The reason for introducing many operations rather than one is the
      signed/unsigned variants can't be distinguished with types (e.g., ui16,
      si16) since 'arith.extui' and 'arith.extsi' only support signless
      integers. A single operation would require this information and an
      attribute (for example) for the sign doesn't feel right if
      floating-point types are also supported where this wouldn't apply.
      Furthermore, the SME FP8 extensions (FEAT_SME_F8F16, FEAT_SME_F8F32)
      introduce FMOPA 2-way (FP8 to FP16) and 4-way (FP8 to FP32) variants but
      no subtract variant. Whilst these are not supported in this patch, it
      felt simpler to have separate ops for add/subtract given this.
      95ef8e38
    • srcarroll's avatar
      [mlir][transform] Add elementwise criteria to `match.structured.body` (#79626) · 488f88b8
      srcarroll authored
      As far as I am aware, there is no simple way to match on elementwise
      ops. I propose to add an `elementwise` criteria to the
      `match.structured.body` op. Although my only hesitation is that
      elementwise is not only determined by the body, but also the indexing
      maps. So if others find this too awkward, I can implement a separate
      match op instead.
      488f88b8
    • Yingwei Zheng's avatar
      [RISCV][MC] Add MC layer support for the experimental zabha extension (#80005) · 89f87c38
      Yingwei Zheng authored
      This patch implements the zabha (Byte and Halfword Atomic Memory
      Operations) v1.0-rc1 extension.
      See also https://github.com/riscv/riscv-zabha/blob/v1.0-rc1/zabha.adoc.
      89f87c38
    • Sander de Smalen's avatar
      [SME] Stop RA from coalescing COPY instructions that transcend beyond smstart/smstop. (#78294) · dd736661
      Sander de Smalen authored
      This patch introduces a 'COALESCER_BARRIER' which is a pseudo node that
      expands to
      a 'nop', but which stops the register allocator from coalescing a COPY
      node when
      its use/def crosses a SMSTART or SMSTOP instruction.
      
      For example:
      
          %0:fpr64 = COPY killed $d0
          undef %2.dsub:zpr = COPY %0       // <- Do not coalesce this COPY
          ADJCALLSTACKDOWN 0, 0
      MSRpstatesvcrImm1 1, 0, csr_aarch64_smstartstop, implicit-def dead $d0
          $d0 = COPY killed %0
          BL @use_f64, csr_aarch64_aapcs
      
      If the COPY would be coalesced, that would lead to:
      
          $d0 = COPY killed %0
      
      being replaced by:
      
          $d0 = COPY killed %2.dsub
      
      which means the whole ZPR reg would be live upto the call, causing the
      MSRpstatesvcrImm1 (smstop) to spill/reload the ZPR register:
      
          str     q0, [sp]   // 16-byte Folded Spill
          smstop  sm
          ldr     z0, [sp]   // 16-byte Folded Reload
          bl      use_f64
      
      which would be incorrect for two reasons:
      1. The program may load more data than it has allocated.
      2. If there are other SVE objects on the stack, the compiler might use
      the
         'mul vl' addressing modes to access the spill location.
      
      By disabling the coalescing, we get the desired results:
      
          str     d0, [sp, #8]  // 8-byte Folded Spill
          smstop  sm
          ldr     d0, [sp, #8]  // 8-byte Folded Reload
          bl      use_f64
      dd736661
    • jinchen62's avatar
      Add support of param type for transform.structured.tile_using_forall (#72097) · d439f364
      jinchen62 authored
      Make transform.structured.tile_using_forall be able to take param type
      tile sizes.
      
      Examples:
      ```
      %tile_sizes = transform.param.constant 16 : i64 -> !transform.param<i64>
      transform.structured.tile_using_forall %matmul tile_sizes [%tile_sizes : !transform.param<i64>, 32] ( mapping = [#gpu.block<x>, #gpu.block<y>] ) : (!transform.any_op) -> (!transform.any_op, !transform.any_op)
      ```
      ```
      %c10 = transform.param.constant 10 : i64 -> !transform.any_param
      %c20 = transform.param.constant 20 : i64 -> !transform.any_param
      %tile_sizes = transform.merge_handles %c10, %c20 : !transform.any_param
      transform.structured.tile_using_forall %matmul tile_sizes *(%tile_sizes : !transform.any_param) ( mapping = [#gpu.block<x>, #gpu.block<y>] ) : (!transform.any_op) -> (!transform.any_op, !transform.any_op)
      ```
      d439f364
    • Timm Baeder's avatar
      [clang][Interp] Support arbitrary precision constants (#79747) · 64a849a5
      Timm Baeder authored
      Add (de)serialization support for them, like we do for Floating values.
      64a849a5
    • Matthias Springer's avatar
      Revert "[mlir][memref] `memref.subview`: Verify result strides" (#80116) · 96c907db
      Matthias Springer authored
      Reverts llvm/llvm-project#79865
      
      I think there is a bug in the stride computation in
      `SubViewOp::inferResultType`. (Was already there before this change.)
      
      Reverting this commit for now and updating the original pull request
      with a fix and more test cases.
      96c907db
    • Jay Foad's avatar
      [CodeGen] Don't include aliases in RegisterClassInfo::IgnoreCSRForAllocOrder (#80015) · f8525030
      Jay Foad authored
      Previously we called ignoreCSRForAllocationOrder on every alias of every
      CSR which was expensive on targets like AMDGPU which define a very large
      number of overlapping register tuples.
      
      On such targets it is simpler and faster to call
      ignoreCSRForAllocationOrder once for every physical register.
      
      Differential Revision: https://reviews.llvm.org/D146735
      f8525030
    • Matthias Springer's avatar
      [mlir][memref] `memref.subview`: Verify result strides (#79865) · db493192
      Matthias Springer authored
      The `memref.subview` verifier currently checks result shape, element
      type, memory space and offset of the result type. However, the strides
      of the result type are currently not verified. This commit adds
      verification of result strides for non-rank reducing ops and fixes
      invalid IR in test cases.
      
      Verification of result strides for ops with rank reductions is more
      complex (and there could be multiple possible result types). That is
      left for a separate commit.
      
      Also refactor the implementation a bit:
      * If `computeMemRefRankReductionMask` could not compute the dropped
      dimensions, there must be something wrong with the op. Return
      `FailureOr` instead of `std::optional`.
      * `isRankReducedMemRefType` did much more than just checking whether the
      op has rank reductions or not. Inline the implementation into the
      verifier and add better comments.
      * `produceSubViewErrorMsg` does not have to be templatized.
      db493192
    • Chia's avatar
      [RISCV][Isel] Remove redundant vmerge for the scalable vwadd(u).wv (#80079) · dc5dca1d
      Chia authored
      Similar to #78403, but for scalable `vwadd(u).wv`, given that #76785 is recommited.
      
      ### Code
      ```
      define <vscale x 8 x i64> @vwadd_wv_mask_v8i32(<vscale x 8 x i32> %x, <vscale x 8 x i64> %y) {
          %mask = icmp slt <vscale x 8 x i32> %x, shufflevector (<vscale x 8 x i32> insertelement (<vscale x 8 x i32> poison, i32 42, i64 0), <vscale x 8 x i32> poison, <vscale x 8 x i32> zeroinitializer)
          %a = select <vscale x 8 x i1> %mask, <vscale x 8 x i32> %x, <vscale x 8 x i32> zeroinitializer
          %sa = sext <vscale x 8 x i32> %a to <vscale x 8 x i64>
          %ret = add <vscale x 8 x i64> %sa, %y
          ret <vscale x 8 x i64> %ret
      }
      ```
      
      ### Before this patch
      [Compiler Explorer](https://godbolt.org/z/xsoa5xPrd)
      ```
      vwadd_wv_mask_v8i32:
              li      a0, 42
              vsetvli a1, zero, e32, m4, ta, ma
              vmslt.vx        v0, v8, a0
              vmv.v.i v12, 0
              vmerge.vvm      v24, v12, v8, v0
              vwadd.wv        v8, v16, v24
              ret
      ```
      
      ### After this patch
      ```
      vwadd_wv_mask_v8i32:
              li a0, 42
              vsetvli a1, zero, e32, m4, ta, ma
              vmslt.vx v0, v8, a0
              vsetvli zero, zero, e32, m4, tu, mu
              vwadd.wv v16, v16, v8, v0.t
              vmv8r.v v8, v16
              ret
      ```
      dc5dca1d
    • Chuanqi Xu's avatar
      [NFC] [clang-repl] Fix test failures due to incosistent target settings · d71831a2
      Chuanqi Xu authored
      See https://github.com/llvm/llvm-project/pull/79261 for details.
      
      It shows that clang-repl uses a different target triple with clang so that it
      may be problematic if the calng-repl reads the generated BMI from clang
      in a different target triple.
      
      While the underlying issue is not easy to fix, this patch tries to make
      this test green to not bother developers.
      d71831a2
    • Yingwei Zheng's avatar
      [InstCombine] Fold select with signbit idiom into fabs (#76342) · f292f90b
      Yingwei Zheng authored
      This patch folds:
      ```
      ((bitcast X to int) <s 0 ? -X : X) -> fabs(X)
      ((bitcast X to int) >s -1 ? X : -X) -> fabs(X)
      ((bitcast X to int) <s 0 ? X : -X) -> -fabs(X)
      ((bitcast X to int) >s -1 ? -X : X) -> -fabs(X)
      ```
      Alive2: https://alive2.llvm.org/ce/z/rGepow
      f292f90b
    • Kazu Hirata's avatar
      [ADT] Use a constexpr version of llvm::bit_ceil (NFC) (#79709) · b49b3ddd
      Kazu Hirata authored
      This patch replaces the template trick with a constexpr function that
      is more readable.  Once C++20 is available in our code base, we can
      remove the constexpr function in favor of std::bit_ceil.
      b49b3ddd
    • martinboehme's avatar
    • Tianlan Zhou's avatar
      [clang] static operators should evaluate object argument (reland) (#80108) · ee01a2c3
      Tianlan Zhou authored
      This re-applies 30155fc0
      
       with a fix for clangd.
      
      ### Description
      
      clang don't evaluate the object argument of `static operator()` and
      `static operator[]` currently, for example:
      
      ```cpp
      #include <iostream>
      
      struct Foo {
          static int operator()(int x, int y) {
              std::cout << "Foo::operator()" << std::endl;
              return x + y;
          }
          static int operator[](int x, int y) {
              std::cout << "Foo::operator[]" << std::endl;
              return x + y;
          }
      };
      Foo getFoo() {
          std::cout << "getFoo()" << std::endl;
          return {};
      }
      int main() {
          std::cout << getFoo()(1, 2) << std::endl;
          std::cout << getFoo()[1, 2] << std::endl;
      }
      ```
      
      `getFoo()` is expected to be called, but clang don't call it currently
      (17.0.6). This PR fixes this issue.
      
      Fixes #67976, reland #68485.
      
      ### Walkthrough
      
      - **clang/lib/Sema/SemaOverload.cpp**
      - **`Sema::CreateOverloadedArraySubscriptExpr` &
      `Sema::BuildCallToObjectOfClassType`**
      Previously clang generate `CallExpr` for static operators, ignoring the
      object argument. In this PR `CXXOperatorCallExpr` is generated for
      static operators instead, with the object argument as the first
      argument.
        - **`TryObjectArgumentInitialization`**
      `const` / `volatile` objects are allowed for static methods, so that we
      can call static operators on them.
      - **clang/lib/CodeGen/CGExpr.cpp**
        - **`CodeGenFunction::EmitCall`**
      CodeGen changes for `CXXOperatorCallExpr` with static operators: emit
      and ignore the object argument first, then emit the operator call.
      - **clang/lib/AST/ExprConstant.cpp**
        - **`‎ExprEvaluatorBase::handleCallExpr‎`**
      Evaluation of static operators in constexpr also need some small changes
      to work, so that the arguments won't be out of position.
      - **clang/lib/Sema/SemaChecking.cpp**
        - **`Sema::CheckFunctionCall`**
      Code for argument checking also need to be modify, or it will fail the
      test `clang/test/SemaCXX/overloaded-operator-decl.cpp`.
      - **clang-tools-extra/clangd/InlayHints.cpp**
        - **`InlayHintVisitor::VisitCallExpr`**
      Now that the `CXXOperatorCallExpr` for static operators also have object
      argument, we should also take care of this situation in clangd.
      
      ### Tests
      
      - **Added:**
          - **clang/test/AST/ast-dump-static-operators.cpp**
            Verify the AST generated for static operators.
          - **clang/test/SemaCXX/cxx2b-static-operator.cpp**
      Static operators should be able to be called on const / volatile
      objects.
      - **Modified:**
          - **clang/test/CodeGenCXX/cxx2b-static-call-operator.cpp**
          - **clang/test/CodeGenCXX/cxx2b-static-subscript-operator.cpp**
            Matching the new CodeGen.
      
      ### Documentation
      
      - **clang/docs/ReleaseNotes.rst**
        Update release notes.
      
      ---------
      
      Co-authored-by: default avatarShafik Yaghmour <shafik@users.noreply.github.com>
      Co-authored-by: default avatarcor3ntin <corentinjabot@gmail.com>
      Co-authored-by: default avatarAaron Ballman <aaron@aaronballman.com>
      ee01a2c3
    • Changpeng Fang's avatar
      [AMDGPU]: Fix type signatures for wmma intrinsics, NFC (#80087) · 3564666f
      Changpeng Fang authored
      Make the wmma intrinsic type signatures to be canonical. We need
      a type signature as long as the type is not fixed. However, when an
      argument's type matches a previous argument's type, we do not need the
      signature for this argument.
      
       This patch fixes three general cases:
        1. add missing signatures
        2. remove signatures for matching arguments
      3. reorer the signatures -- return type signature should always appear
      first
      3564666f
    • martinboehme's avatar
      [clang][dataflow] Extend debug output for `Environment`. (#79982) · c83ec847
      martinboehme authored
      *  Print `ReturnLoc`, `ReturnVal`, and `ThisPointeeLoc` if applicable.
      
      * For entries in `LocToVal` that correspond to declarations, print the
      names
         of the declarations next to them.
      
      I've removed the FIXME because all relevant fields are now being dumped.
      I'm
      not sure we actually need the capability for the caller to specify which
      fields
      to dump, so I've simply deleted this part of the comment.
      
      Some examples of the output:
      
      
      ![image](https://github.com/llvm/llvm-project/assets/29098113/17d0978f-b86d-4555-8a61-d1f2021f8d59)
      
      
      ![image](https://github.com/llvm/llvm-project/assets/29098113/021dbb24-5fe2-4720-8a08-f48dcf4b88f8)
      c83ec847
    • Piggy's avatar
      [NFC] Add compiler-rt:* to .github/new-prs-labeler.yml (#79872) · 95947465
      Piggy authored
      After this change, all current compiler-rt:* labels on GitHub are
      covered.
      95947465
    • Piggy's avatar
      [NFC] Update .git-blame-ignore-revs for compiler-rt builtins (#79803) · 6f35f1d7
      Piggy authored
      The three commits from "[RFC] compiler-rt builtins cleanup and
      refactoring" rewrote lots of code in compiler-rt builtins.
      
      - 082b89b2: [builtins] Reformat builtins with clang-format
      - 0ba22f51: [builtins] Use single line C++/C99 comment style
      - 84da0e1b: [builtins] Use aliases for function redirects
      6f35f1d7
    • Timm Baeder's avatar
      [clang][Interp] Add inline descriptor to global variables (#72892) · 5bb99edc
      Timm Baeder authored
      Some time ago, I did a similar patch for local variables.
      
      Initializing global variables can fail as well:
      ```c++
      constexpr int a = 1/0;
      static_assert(a == 0);
      ```
      ... would succeed in the new interpreter, because we never saved the
      fact that `a` has not been successfully initialized.
      5bb99edc
    • Yingwei Zheng's avatar
      [InstCombine] Simplify and/or by replacing operands with constants (#77231) · f2816ff6
      Yingwei Zheng authored
      This patch tries to simplify `X | Y` by replacing occurrences of `Y` in
      `X` with 0. Similarly, it tries to simplify `X & Y` by replacing
      occurrences of `Y` in `X` with -1.
      
      Alive2: https://alive2.llvm.org/ce/z/cNjDTR
      Note: As the current implementation is too conservative in the one-use
      checks, I cannot remove other existing hard-coded simplifications if
      they involves more than two instructions (e.g, `A & ~(A ^ B) --> A &
      B`).
      
      Compile-time impact:
      http://llvm-compile-time-tracker.com/compare.php?from=a085402ef54379758e6c996dbaedfcb92ad222b5&to=9d655c6685865ffce0ad336fed81228f3071bd03&stat=instructions%3Au
      
      |stage1-O3|stage1-ReleaseThinLTO|stage1-ReleaseLTO-g|stage1-O0-g|stage2-O3|stage2-O0-g|stage2-clang|
      |--|--|--|--|--|--|--|
      |+0.01%|-0.00%|+0.00%|-0.02%|+0.01%|+0.02%|-0.01%|
      
      Fixes #76554.
      f2816ff6
    • Craig Topper's avatar
      [RISCV] Use disjoint flag in or_is_add. · 8a980911
      Craig Topper authored
      8a980911
    • Kazu Hirata's avatar
      [AMDGPU] Use StringRef::consume_front (NFC) · 292b508e
      Kazu Hirata authored
      292b508e
    • Kazu Hirata's avatar
      2699c1d7
    • Kazu Hirata's avatar
      [AMDGPU] Use llvm::all_of (NFC) · eef6485a
      Kazu Hirata authored
      eef6485a
    • Kazu Hirata's avatar
      [X86] Use a range-based for loop (NFC) · 5d7a0a73
      Kazu Hirata authored
      5d7a0a73
    • Yingwei Zheng's avatar
      [CVP] Check whether the default case is reachable (#79993) · a034e65e
      Yingwei Zheng authored
      This patch eliminates unreachable default cases using context-sensitive
      range information.
      a034e65e
    • Shengchen Kan's avatar
    • Ben Shi's avatar
    • Shengchen Kan's avatar
      [X86][NFC] Add documentation for methods in X86InstrInfo.h · 150ab995
      Shengchen Kan authored
      Address RKSimon's comment in 2960656e
      150ab995
    • Craig Topper's avatar
      [RISCV] Remove unused RISCVISD opcodes. NFC · 9179d87a
      Craig Topper authored
      These were left behind after fb94c649
      9179d87a
    • Karthika Devi C's avatar
      [polly] Make reduction detection checks more robust - part 1 (#75297) · fa3307eb
      Karthika Devi C authored
      Existing reduction detection algorithm does two types of memory checks
      before marking a load store pair as reduction.
      
      First is to check if load and store are pointing to the same memory. This
      check right now detects the following case as reduction. sum[0] = sum[1]
      + A[i]
      
      This is because the check compares only base of the memory addresses
      involved and not their indices. This patch addresses this issue and
      introduces some debug prints. Added couple of test cases to verify the
      functionality of patch as well.
      fa3307eb
    • Younan Zhang's avatar
      [concepts] Push a CurContext before substituting into out-of-line constraints... · ab70ac60
      Younan Zhang authored
      [concepts] Push a CurContext before substituting into out-of-line constraints for comparison (#79985)
      
      ab70ac60
    • Joseph Huber's avatar
      [NVPTX] Allow compiling LLVM-IR without `-march` set (#79873) · 7155c1ef
      Joseph Huber authored
      Summary:
      The NVPTX tools require an architecture to be used, however if we are
      creating generic LLVM-IR we should be able to leave it unspecified. This
      will result in the `target-cpu` attributes not being set on the
      functions so it can be changed when linked into code. This allows the
      standalone `--target=nvptx64-nvidia-cuda` toolchain to create LLVM-IR
      simmilar to how CUDA's deviceRTL looks from C/C++
      7155c1ef
    • Kohei Yamaguchi's avatar
      [mlir][spirv] Fix a crash of typeConverter with non supported type (#79955) · c19436ee
      Kohei Yamaguchi authored
      Fixes a crash in the `convert-to-spirv-llvm` pass caused by unsupported
      types (e.g. `spirv.matrix` ). This PR fixes it by checking the converted type.
      
      Fixes #60017
      c19436ee
    • Oskar Wirga's avatar
      Refactor recomputeLiveIns to converge on added MachineBasicBlocks (#79940) · ff4636a4
      Oskar Wirga authored
      This is a fix for the regression seen in
      https://github.com/llvm/llvm-project/pull/79498
      
      > Currently, the way that recomputeLiveIns works is that it will
      recompute the livein registers for that MachineBasicBlock but it matters
      what order you call recomputeLiveIn which can result in incorrect
      register allocations down the line.
      
      Now we do not recompute the entire CFG but we do ensure that the newly
      added MBB do reach convergence.
      ff4636a4
    • Congcong Cai's avatar
      Revert "[WebAssembly] avoid to use explicit disabled feature" · c43fda3e
      Congcong Cai authored
      This reverts commit 1a17f2be.
      c43fda3e
    • Congcong Cai's avatar
      [WebAssembly] avoid to use explicit disabled feature · 1a17f2be
      Congcong Cai authored
      In `CoalesceFeaturesAndStripAtomics`, feature string is converted to FeatureBitset and back to feature string. It will lose information about explicit diasbled features.
      1a17f2be
    • Billy Laws's avatar
      [AArch64] Fix variadic tail-calls on ARM64EC (#79774) · c761b4a5
      Billy Laws authored
      ARM64EC varargs calls expect that x4 = sp at entry, special handling is
      needed to ensure this with tail calls since they occur after the
      epilogue and the x4 write happens before.
      
      I tried going through AArch64MachineFrameLowering for this, hoping to
      avoid creating the dummy object but this was the best I could do since
      the stack info that uses isn't populated at this stage,
      CreateFixedObject also explicitly forbids 0 sized objects.
      c761b4a5
    • Carl Peto's avatar
      [clang] Improved isSimpleTypeSpecifier (#79037) · b4d832c7
      Carl Peto authored
      
      
      - Sema::isSimpleTypeSpecifier return true for _Bool in c99 (currently
      returns false for _Bool, regardless of C dialect). (Fixes #72203)
      - replace the logic with a check for simple types and a proper check for
      a valid keyword in the appropriate dialect
      
      Co-authored-by: default avatarCarl Peto <CPeto@becrypt.com>
      b4d832c7