llvm-project/llvm/test/Transforms/LoopVectorize/AArch64
David Sherwood 26b7d9d622 [LoopVectorize] Permit vectorisation of more select(cmp(), X, Y) reduction patterns
This patch adds further support for vectorisation of loops that involve
selecting an integer value based on a previous comparison. Consider the
following C++ loop:

  int r = a;
  for (int i = 0; i < n; i++) {
    if (src[i] > 3) {
      r = b;
    }
    src[i] += 2;
  }

We should be able to vectorise this loop because all we are doing is
selecting between two states - 'a' and 'b' - both of which are loop
invariant. This just involves building a vector of values that contain
either 'a' or 'b', where the final reduced value will be 'b' if any lane
contains 'b'.

The IR generated by clang typically looks like this:

  %phi = phi i32 [ %a, %entry ], [ %phi.update, %for.body ]
  ...
  %pred = icmp ugt i32 %val, i32 3
  %phi.update = select i1 %pred, i32 %b, i32 %phi

We already detect min/max patterns, which also involve a select + cmp.
However, with the min/max patterns we are selecting loaded values (and
hence loop variant) in the loop. In addition we only support certain
cmp predicates. This patch adds a new pattern matching function
(isSelectCmpPattern) and new RecurKind enums - SelectICmp & SelectFCmp.
We only support selecting values that are integer and loop invariant,
however we can support any kind of compare - integer or float.

Tests have been added here:

  Transforms/LoopVectorize/AArch64/sve-select-cmp.ll
  Transforms/LoopVectorize/select-cmp-predicated.ll
  Transforms/LoopVectorize/select-cmp.ll

Differential Revision: https://reviews.llvm.org/D108136
2021-10-11 09:41:38 +01:00
..
Oz-and-forced-vectorize.ll
aarch64-predication.ll [LV] Mark increment of main vector loop induction variable as NUW. 2021-06-07 10:47:52 +01:00
aarch64-unroll.ll
arbitrary-induction-step.ll [LV] Mark increment of main vector loop induction variable as NUW. 2021-06-07 10:47:52 +01:00
arm64-unroll.ll
backedge-overflow.ll
deterministic-type-shrinkage.ll
eliminate-tail-predication.ll [LV] Add -scalable-vectorization=<option> flag. 2021-05-19 10:40:56 +01:00
extend-vectorization-factor-for-unprofitable-memops.ll [AArch64] Cost-model i8 vector loads/stores 2021-07-05 11:25:10 +01:00
extractvalue-no-scalarization-required.ll [LV] Consider ExtractValue as uniform. 2021-08-05 16:20:50 +01:00
first-order-recurrence.ll [SVE] Remove usage of getMaxVScale for AArch64, in favour of IR Attribute 2021-08-17 14:42:47 +01:00
gather-cost.ll
induction-trunc.ll [LV] Mark increment of main vector loop induction variable as NUW. 2021-06-07 10:47:52 +01:00
interleaved-store-of-first-order-recurrence.ll [LV] Add test to store a first-order rec via interleave group. 2021-07-26 15:20:04 +01:00
interleaved-vs-scalar.ll [AArch64] Cost-model i8 vector loads/stores 2021-07-05 11:25:10 +01:00
interleaved_cost.ll
intrinsiccost.ll [CostModel] Update default cost model for sadd/ssub overflow to match TargetLowering 2021-09-30 09:41:14 -07:00
lit.local.cfg
loop-vectorization-factors.ll [LV] Mark increment of main vector loop induction variable as NUW. 2021-06-07 10:47:52 +01:00
loopvectorize_pr33804_double.ll Revert "[NFC] remove explicit default value for strboolattr attribute in tests" 2021-05-24 19:43:40 +02:00
masked-op-cost.ll [LV] Build and cost VPlans for scalable VFs. 2021-06-02 14:47:47 +01:00
max-vf-for-interleaved.ll
no_vector_instructions.ll [LoopVectorize] Simplify scalar cost calculation in getInstructionCost 2021-04-28 13:41:07 +01:00
nontemporal-load-store.ll
outer_loop_test1_no_explicit_vect_width.ll [LV] Mark increment of main vector loop induction variable as NUW. 2021-06-07 10:47:52 +01:00
pr31900.ll
pr33053.ll Revert "[NFC] remove explicit default value for strboolattr attribute in tests" 2021-05-24 19:43:40 +02:00
pr36032.ll
pr46950-load-cast-context-crash.ll
predication_costs.ll [LV] Don't assume isScalarAfterVectorization if one of the uses needs widening. 2021-07-26 16:01:55 +01:00
reduction-small-size.ll
runtime-check-size-based-threshold.ll [LV] Add tests where rt checks may make vectorization unprofitable. 2021-09-27 10:32:28 +01:00
scalable-alloca.ll [LV] Avoid scalable vectorization for loops containing alloca 2021-07-16 11:47:13 +01:00
scalable-call.ll [LV] Don't let ForceTargetInstructionCost override Invalid cost. 2021-07-26 20:27:49 +01:00
scalable-predicate-instruction.ll [LoopVectorize] Fix crash for predicated instruction with scalable VF 2021-07-22 12:48:27 +01:00
scalable-reductions.ll [LV] Prevent vectorization with unsupported element types. 2021-07-06 13:06:21 +01:00
scalable-strict-fadd.ll Recommit "[LoopVectorize][AArch64] Enable ordered reductions by default for AArch64" 2021-08-23 11:25:27 +01:00
scalable-vectorization.ll [SVE] Remove usage of getMaxVScale for AArch64, in favour of IR Attribute 2021-08-17 14:42:47 +01:00
scalable-vf-hint.ll [SVE] Remove usage of getMaxVScale for AArch64, in favour of IR Attribute 2021-08-17 14:42:47 +01:00
scalarize-store-with-predication.ll [LoopVectorize] Fix bug where predicated loads/stores were dropped 2021-04-22 15:05:54 +00:00
sdiv-pow2.ll
select-costs.ll
smallest-and-widest-types.ll
strict-fadd-cost.ll [Analysis][AArch64] Make fixed-width ordered reductions slightly more expensive 2021-08-18 17:01:56 +01:00
strict-fadd-vf1.ll [NFC] Rename enable-strict-reductions to force-ordered-reductions 2021-08-03 09:33:01 +01:00
strict-fadd.ll Recommit "[LoopVectorize][AArch64] Enable ordered reductions by default for AArch64" 2021-08-23 11:25:27 +01:00
sve-basic-vec.ll [LV] Add -scalable-vectorization=<option> flag. 2021-05-19 10:40:56 +01:00
sve-cond-inv-loads.ll [SVE] Remove usage of getMaxVScale for AArch64, in favour of IR Attribute 2021-08-17 14:42:47 +01:00
sve-extract-last-veclane.ll [LV] Add -scalable-vectorization=<option> flag. 2021-05-19 10:40:56 +01:00
sve-gather-scatter.ll [SVE] Remove usage of getMaxVScale for AArch64, in favour of IR Attribute 2021-08-17 14:42:47 +01:00
sve-illegal-type.ll [LV] Prevent vectorization with unsupported element types. 2021-07-06 13:06:21 +01:00
sve-inductions.ll [AArch64] NFC: Make some AArch64-SVE LoopVectorize tests generic. 2021-07-26 20:27:48 +01:00
sve-inv-loads.ll [LV] Add -scalable-vectorization=<option> flag. 2021-05-19 10:40:56 +01:00
sve-inv-store.ll [SVE] Remove usage of getMaxVScale for AArch64, in favour of IR Attribute 2021-08-17 14:42:47 +01:00
sve-large-strides.ll [SVE] Remove usage of getMaxVScale for AArch64, in favour of IR Attribute 2021-08-17 14:42:47 +01:00
sve-masked-loadstore.ll [LV] Add -scalable-vectorization=<option> flag. 2021-05-19 10:40:56 +01:00
sve-scalable-load-in-loop.ll [SVE] Remove checks for warnings in scalable-vector tests. 2021-04-07 15:59:32 +01:00
sve-select-cmp.ll [LoopVectorize] Permit vectorisation of more select(cmp(), X, Y) reduction patterns 2021-10-11 09:41:38 +01:00
sve-strict-fadd-cost.ll [SVE] Remove usage of getMaxVScale for AArch64, in favour of IR Attribute 2021-08-17 14:42:47 +01:00
sve-tail-folding.ll [LV] Disable Scalable VFs when tail folding is enabled b/c of low tripcount. 2021-07-27 11:37:21 +01:00
sve-type-conv.ll [LV] Add -scalable-vectorization=<option> flag. 2021-05-19 10:40:56 +01:00
sve-vector-reverse-mask4.ll [InstCombine] Eliminate vector reverse if all inputs/outputs to an instruction are reverses 2021-09-20 18:32:24 -07:00
sve-vector-reverse.ll [InstCombine] Eliminate vector reverse if all inputs/outputs to an instruction are reverses 2021-09-20 18:32:24 -07:00
sve-widen-extractvalue.ll [LV] Consider ExtractValue as uniform. 2021-08-05 16:20:50 +01:00
sve-widen-gep.ll [SVE][LoopVectorize] Optimise code generated by widenPHIInstruction 2021-09-10 11:58:04 +01:00
sve-widen-phi.ll [Analysis] Add support for vscale in computeKnownBitsFromOperator 2021-09-20 15:01:59 +01:00
type-shrinkage-insertelt.ll
unsafe-vf-hint-remark.ll
veclib-calls-libsystem-darwin.ll [VecLib] Add support for vector fns from Darwin's libsystem. 2021-05-10 21:19:58 +01:00
vector-reverse-mask4.ll Revert rG1c9bec727ab5c53fa060560dc8d346a911142170 : [InstCombine] Fold (gep (oneuse(gep Ptr, Idx0)), Idx1) -> (gep Ptr, (add Idx0, Idx1)) (PR51069) 2021-08-23 21:09:26 +01:00
vector-reverse.ll [SVE] Remove checks for warnings in scalable-vector tests. 2021-04-07 15:59:32 +01:00