1. Jan 31, 2024
    • Simon Pilgrim's avatar
      [X86] cfguard - replace X32 check prefixes with X86 · 1d8c8f11
      Simon Pilgrim authored
      We try to only use X32 for gnux32 triple tests.
      1d8c8f11
    • Simon Pilgrim's avatar
      [X86] fold-vector-sext - replace X32 check prefixes with X86 · 824d073f
      Simon Pilgrim authored
      We try to only use X32 for gnux32 triple tests.
      824d073f
    • Simon Pilgrim's avatar
      [X86] divide-by-constant.ll - replace X32 check prefixes with X86 · ed11f255
      Simon Pilgrim authored
      We try to only use X32 for gnux32 triple tests.
      ed11f255
    • Simon Pilgrim's avatar
      [X86] divrem.ll - replace X32 check prefixes with X86 · e4af212f
      Simon Pilgrim authored
      We try to only use X32 for gnux32 triple tests.
      e4af212f
    • Simon Pilgrim's avatar
      [X86] insertps-from-constantpool.ll - replace X32 check prefixes with X86 and expose address math · a82ca1cd
      Simon Pilgrim authored
      We try to only use X32 for gnux32 triple tests.
      
      Use no_x86_scrub_mem_shuffle so the test shows updated shuffle intermediate and the +4 offset into the constant pool vector entry
      a82ca1cd
    • Simon Pilgrim's avatar
      [DAG] AddNodeIDCustom - call ShuffleVectorSDNode::getMask once instead of... · 912cdd21
      Simon Pilgrim authored
      [DAG] AddNodeIDCustom - call ShuffleVectorSDNode::getMask once instead of repeated getMaskElt calls.
      
      Use a simpler for-range loop to append all shuffle mask elements
      912cdd21
    • Benjamin Maxwell's avatar
      [mlir][ArmSME] Add initial SME vector legalization pass (#79152) · 042800a4
      Benjamin Maxwell authored
      This adds a new pass (`-arm-sme-vector-legalization`) which legalizes
      vector operations so that they can be lowered to ArmSME. This initial
      patch adds decomposition for `vector.outerproduct`,
      `vector.transfer_read`, and `vector.transfer_write` when they operate on
      vector types larger than a single SME tile. For example, a [8]x[8]xf32
      outer product would be decomposed into four [4]x[4]xf32 outer products,
      which could then be lowered to ArmSME. These three ops have been picked
      as supporting them alone allows lowering matmuls that use all ZA
      accumulators to ArmSME.
      
      For it to be possible to legalize a vector type it has to be a multiple
      of an SME tile size, but other than that any shape can be used. E.g.
      `vector<[8]x[8]xf32>`, `vector<[4]x[16]xf32>`, `vector<[16]x[4]xf32>`
      can all be lowered to four `vector<[4]x[4]xf32>` operations.
      
      In future, this pass will be extended with more SME-specific rewrites to
      legalize unrolling the reduction dimension of matmuls (which is not
      type-decomposition), which is why the pass has quite a general name.
      042800a4
    • Billy Laws's avatar
      d74619ab
    • Billy Laws's avatar
      [llvm-rc] Support ARM64EC resource generation (#78908) · d55d72e9
      Billy Laws authored
      This is already supported in llvm-cvtres, so only a small change is
      needed.
      d55d72e9
    • Nashe Mncube's avatar
      [llvm][InstCombine] bitcast bfloat half castpair bug (#79832) · d309261d
      Nashe Mncube authored
      Miscompilation arises due to instruction combining of cast pairs of the
      type `bitcast bfloat to half` + `<FPOp> bfloat to half` or `bitcast half
      to bfloat` + `<FPOp half to bfloat`. For example `bitcast bfloat to
      half`+`fpext half to double` or `bitcast bfloat to half`+`fpext bfloat
      to double` respectively reduce to `fpext bfloat to double` and `fpext
      half to double`. This is an incorrect conversion as it assumes the
      representation of `bfloat` and `half` are equivalent due to having the
      same width. As a consequence miscompilation arises.
      
      Fixes #61984
      d309261d
    • Sander de Smalen's avatar
      [AArch64][SME] Fix inlining bug introduced in #78703 (#79994) · 3abf55a6
      Sander de Smalen authored
      Calling a `__arm_locally_streaming` function from a function that
      is not a streaming-SVE function would lead to incorrect inlining.
      
      The issue didn't surface because the tests were not testing what
      they were supposed to test.
      3abf55a6
    • SunilKuravinakop's avatar
      [OpenMP] atomic compare weak : Parser & AST support (#79475) · a74e9ce5
      SunilKuravinakop authored
      
      
      This is a support for " #pragma omp atomic compare weak". It has Parser
      & AST support for now.
      
      ---------
      
      Authored-by: default avatarSunil Kuravinakop <kuravina@pe28vega.us.cray.com>
      a74e9ce5
    • Nikita Popov's avatar
      [AsmParser] Add missing globals declarations in incomplete IR mode (#79855) · 5cc87b42
      Nikita Popov authored
      If `-allow-incomplete-ir` is enabled, automatically insert declarations
      for missing globals.
      
      If a global is only used in calls with the same function type, insert a
      function declaration with that type.
      
      Otherwise, insert a dummy i8 global. The fallback case could be extended
      with various heuristics (e.g. we could look at load/store types), but
      I've chosen to keep it simple for now, because I'm unsure to what degree
      this would really useful without more experience. I expect that in most
      cases the declaration type doesn't really matter (note that the type of
      an external global specifies a *minimum* size only, not a precise size).
      
      This is a followup to https://github.com/llvm/llvm-project/pull/78421.
      5cc87b42
    • Nikita Popov's avatar
      [BDCE] Also drop poison-generating metadata · cb6240d2
      Nikita Popov authored
      The comment was incorrect: !range also applies to calls, and we
      do need to drop it in some cases.
      cb6240d2
    • Dominik Adamski's avatar
      [OpenMPIRBuilder] Do not call host runtime for GPU teams codegen (#79984) · b4370140
      Dominik Adamski authored
      Patch ensures that host runtime functions are not called for handling
      OpenMP teams clause on the device.
      
      GPU code for pragma `omp target teams distribute parallel do` will
      require only one call to OpenMP loop-worksharing GPU runtime. Support
      for it will be added later.
      
      This patch does not include changes required for handling `omp target
      teams` for the host side.
      b4370140
    • Simon Pilgrim's avatar
    • Simon Pilgrim's avatar
      [X86] v2f32.ll - replace X32 check prefixes with X86 (and add common CHECK prefix) · 929503ea
      Simon Pilgrim authored
      We try to only use X32 for gnux32 triple tests.
      929503ea
    • Simon Pilgrim's avatar
      [X86] v4f32-immediate.ll - replace X32 check prefixes with X86 · 00a68171
      Simon Pilgrim authored
      We try to only use X32 for gnux32 triple tests.
      00a68171
    • Simon Pilgrim's avatar
      [X86] mmx-arith.ll - replace X32 check prefixes with X86 + strip cfi noise · 8d450b47
      Simon Pilgrim authored
      We try to only use X32 for gnux32 triple tests.
      8d450b47
    • Simon Pilgrim's avatar
    • Vyacheslav Levytskyy's avatar
      [SPIR-V] Improve how lowering of formal arguments in SPIR-V Backend interprets... · 5a07774f
      Vyacheslav Levytskyy authored
      [SPIR-V] Improve how lowering of formal arguments in SPIR-V Backend interprets a value of 'kernel_arg_type' (#78730)
      
      The goal of this PR is to tolerate differences between description of
      formal arguments by function metadata (represented by "kernel_arg_type")
      and LLVM actual parameter types. A compiler may use "kernel_arg_type" of
      function metadata fields to encode detailed type information, whereas
      LLVM IR may utilize for an actual parameter a more general type, in
      particular, opaque pointer type. This PR proposes to resolve this by a
      fallback to LLVM actual parameter types during the lowering of formal
      function arguments in cases when the type can't be created by string
      content of "kernel_arg_type", i.e., when "kernel_arg_type" contains a
      type unknown for the SPIR-V Backend.
      
      An example of the issue manifestation is
      https://github.com/KhronosGroup/SPIRV-LLVM-Translator/blob/main/test/transcoding/KernelArgTypeInOpString.ll,
      where a compiler generates for the following kernel function detailed
      `kernel_arg_type` info in a form of `!{!"image_kernel_data*", !"myInt",
      !"struct struct_name*"}`, and in LLVM IR same arguments are referred to
      as `@foo(ptr addrspace(1) %in, i32 %out, ptr addrspace(1) %outData)`.
      Both definitions are correct, and the resulting LLVM IR is correct, but
      lowering stage of SPIR-V Backend fails to generate SPIR-V type.
      
      ```
      typedef int myInt;
      
       typedef struct {
         int width;
         int height;
       } image_kernel_data;
      
       struct struct_name {
         int i;
         int y;
       };
       void kernel foo(__global image_kernel_data* in,
                       __global struct struct_name *outData,
                       myInt out) {}
      ```
      
      ```
      define spir_kernel void @foo(ptr addrspace(1) %in, i32 %out, ptr addrspace(1) %outData) ... !kernel_arg_type !7 ... {
      entry:
        ret void
      }
      ...
      !7 = !{!"image_kernel_data*", !"myInt", !"struct struct_name*"}
      ```
      
      The PR changes a contract of `SPIRVType *getArgSPIRVType(...)` in a way
      that it may return `nullptr` to signal that the metadata string content
      is not recognized, so corresponding comments are added and a couple of
      checks for `nullptr` are inserted where appropriate.
      5a07774f
    • Simon Camphausen's avatar
      [mlir][EmitC] Add `verbatim` op (#79584) · e624648b
      Simon Camphausen authored
      
      
      The `verbatim` operation produces no results and the value is emitted as
      is followed by a line break ('\n' character) during translation.
      
      Note: Use with caution. This operation can have arbitrary effects on the
      semantics of the emitted code. Use semantically more meaningful
      operations whenever possible. Additionally this op is *NOT* intended to
      be used to inject large snippets of code.
      
      This operation can be used in situations where a more suitable operation
      is not yet implemented in the dialect or where preprocessor directives
      interfere with the structure of the code.
      
      Co-authored-by: default avatarMarius Brehler <marius.brehler@iml.fraunhofer.de>
      e624648b
    • Robert Konicar's avatar
      [mlir] Fix debug output for passes that modify top-level operation. (#80022) · 78e0cca1
      Robert Konicar authored
      Make it so that when the top-level (root) operation itself is being
      modified, it is also used as the root for debug output in
      PatternApplicator.
      
      Fix #80021
      78e0cca1
    • David Spickett's avatar
      [clang][AMDGPU] Remove trialing whitespace in doc · 0217d2e0
      David Spickett authored
      Added by f2a78e68.
      
      Wouldn't normally bother but it's showing up in some CI checks,
      just want to reduce the noise.
      0217d2e0
    • Jay Foad's avatar
      [AMDGPU] Stop combining arbitrary offsets into PAL relocs (#80034) · c2c650f6
      Jay Foad authored
      PAL uses ELF REL (not RELA) relocations which can only store a 32-bit
      addend in the instruction, even for reloc types like R_AMDGPU_ABS32_HI
      which require the upper 32 bits of a 64-bit address calculation to be
      correct. This means that it is not safe to fold an arbitrary offset into
      a GlobalAddressSDNode, so stop doing that.
      
      In practice this is mostly a problem for small negative offsets which do
      not work as expected because PAL treats the 32-bit addend as unsigned.
      c2c650f6
    • Yingwei Zheng's avatar
      [ValueTracking] Merge `cannotBeOrderedLessThanZeroImpl` into `computeKnownFPClass` (#76360) · 50e80e06
      Yingwei Zheng authored
      
      
      This patch merges the logic of `cannotBeOrderedLessThanZeroImpl` into
      `computeKnownFPClass` to improve the signbit inference.
      
      ---------
      
      Co-authored-by: default avatarMatt Arsenault <arsenm2@gmail.com>
      50e80e06
    • Jay Foad's avatar
      Revert "[CodeGen] Don't include aliases in RegisterClassInfo::IgnoreCSRForAllocOrder (#80015)" · 942cc9a2
      Jay Foad authored
      This reverts commit f8525030.
      
      It was supposed to speed things up but llvm-compile-time-tracker.com
      showed a slight slow down.
      942cc9a2
    • Matthias Springer's avatar
      [mlir][IR] Add `RewriterBase::moveBlockBefore` and fix bug in `moveOpBefore` (#79579) · da784a25
      Matthias Springer authored
      This commit adds a new method to the rewriter API: `moveBlockBefore`.
      This op is utilized by `inlineRegionBefore` and covered by dialect
      conversion test cases.
      
      Also fixes a bug in `moveOpBefore`, where the previous op location was
      not passed correctly. Adds a test case to
      `test-strict-pattern-driver.mlir`.
      da784a25
    • Nikita Popov's avatar
      [BDCE] Fix clearing of poison-generating flags · b210cbbd
      Nikita Popov authored
      If the demanded bits of an instruction are full, we don't have to
      recurse to its users, but we may still have to clear flags on the
      instruction itself.
      
      Fixes https://github.com/llvm/llvm-project/issues/80113.
      b210cbbd
    • Timm Baeder's avatar
    • David Spickett's avatar
      [GitHub][workflows] Add buildbot information comment to first merged PR from a... · 44ba4c73
      David Spickett authored
      [GitHub][workflows] Add buildbot information comment to first merged PR from a new contributor (#78292)
      
      This change adds a comment to the first PR from a new contributor that
      is merged, which tells them what to expect post merge from the build
      bots.
      
      How they will be notified, where to ask questions, that you're more
      likely to be reverted than in other projects, etc. The information
      overlaps with, and links to
      https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr.
      So that users who simply read the email are still aware, and know where
      to follow up if they do get reports.
      
      To do this, I have added a hidden HTML comment to the new contributor
      greeting comment. This workflow will look for that to tell if the author
      of the PR was a new contributor at the time they opened the merge. It
      has to be done this way because as soon as the PR is merged, they are by
      GitHub's definition no longer a new contributor and I suspect that their
      author association will be "contri...
      44ba4c73
    • Nikita Popov's avatar
      [BDCE] Add tests for #80113 (NFC) · db1fbd65
      Nikita Popov authored
      db1fbd65
    • Matthias Springer's avatar
      [mlir][memref] `memref.subview`: Verify result strides · ce7cc723
      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.
      * Fix comment and add additional assert to `ExpandStridedMetadata.cpp`, to make sure that the memref.subview verifier is in sync with the memref.subview -> memref.reinterpret_cast lowering.
      
      Note: This change is identical to #79865, but with a fixed comment and an additional assert in `ExpandStridedMetadata.cpp`. (I reverted #79865 in #80116, but the implementation was actually correct, just the comment in `ExpandStridedMetadata.cpp` was confusing.)
      ce7cc723
    • Benjamin Maxwell's avatar
      [mlir][vector] Disable transpose -> shuffle lowering for scalable vectors (#79979) · 88610b79
      Benjamin Maxwell authored
      vector.shuffle is not supported for scalable vectors (outside of splats)
      88610b79
    • 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