SuccessChanges

Summary

  1. [LoopVectorize] Fix VPRecipeBuilder::createEdgeMask to correctly generate the mask (details)
  2. [InstCombine] Add nonnull(select c, null, p) tests (NFC) (details)
  3. [InstCombine] fold fdiv with pow divisor (PR49147) (details)
  4. [ASTMatchers] Clarify example in docs (details)
  5. [ValueTracking] Dereferenced pointers are noundef (details)
  6. [mlir][Linalg] Fix constant detection in linalg.pad_tensor vectorization. (details)
  7. [BasicAA] Use index difference to detect GEPs with identical indexes (details)
  8. [BasicAA] Avoid duplicate query for GEPs with identical offsets (NFCI) (details)
  9. [Analysis] Use ListSeparator (NFC) (details)
  10. [llvm] Fix header guards (NFC) (details)
  11. [llvm] Use llvm::is_contained (NFC) (details)
Commit ed253ef77248d91a15b3a1aa36c0b74bed8ec8af by aqjune
[LoopVectorize] Fix VPRecipeBuilder::createEdgeMask to correctly generate the mask

This patch fixes pr48832 by correctly generating the mask when a poison value is involved.

Consider this CFG (which is a part of the input):

```
for.body:                                         ; preds = %for.cond
  br i1 true, label %cond.false, label %land.rhs

land.rhs:                                         ; preds = %for.body
  br i1 poison, label %cond.end, label %cond.false

cond.false:                                       ; preds = %for.body, %land.rhs
  br label %cond.end

cond.end:                                         ; preds = %land.rhs, %cond.false
  %cond = phi i32 [ 0, %cond.false ], [ 1, %land.rhs ]

```

The path for.body -> land.rhs -> cond.end should be taken when 'select i1 false, i1 poison, i1 false' holds (which means it's never taken); but VPRecipeBuilder::createEdgeMask was emitting 'and i1 false, poison' instead.
The former one successfully blocks poison propagation whereas the latter one doesn't, making the condition poison and thus causing the miscompilation.

SimplifyCFG has a similar bug (which didn't expose a real-world bug yet), and a patch for this is also ongoing (see https://reviews.llvm.org/D95026).

Reviewed By: bjope

Differential Revision: https://reviews.llvm.org/D95217
The file was modifiedllvm/test/Transforms/LoopVectorize/reduction-inloop-pred.ll (diff)
The file was addedllvm/test/Transforms/LoopVectorize/pr48832.ll
The file was modifiedllvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h (diff)
The file was modifiedllvm/test/Transforms/LoopVectorize/X86/masked_load_store.ll (diff)
The file was modifiedllvm/test/Transforms/LoopVectorize/if-pred-non-void.ll (diff)
The file was modifiedllvm/test/Transforms/LoopVectorize/X86/x86-interleaved-accesses-masked-group.ll (diff)
The file was modifiedllvm/test/Transforms/LoopVectorize/reduction-inloop.ll (diff)
The file was modifiedllvm/lib/Transforms/Vectorize/LoopVectorize.cpp (diff)
The file was modifiedllvm/test/Transforms/LoopVectorize/if-reduction.ll (diff)
The file was modifiedllvm/test/Transforms/LoopVectorize/if-conversion-nest.ll (diff)
Commit 2c5c7d5feb7e57f533f0ba3d96785b5e14b94ba0 by aqjune
[InstCombine] Add nonnull(select c, null, p) tests (NFC)
The file was addedllvm/test/Transforms/InstCombine/nonnull-select.ll
Commit b40fde062c306584d88243de11175187e754ce3b by spatel
[InstCombine] fold fdiv with pow divisor (PR49147)

This is unusual in the general (non-reciprocal) case because we need
an extra instruction, but that should be better for general FP
reassociation and codegen. We conservatively check for "arcp" FMF
here as we do with existing fdiv folds, but it is not strictly
necessary to have that.

This is part of solving:
https://llvm.org/PR49147
(The powi variant potentially has a different constraint.)

Differential Revision: https://reviews.llvm.org/D96648
The file was modifiedllvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp (diff)
The file was modifiedllvm/test/Transforms/InstCombine/fdiv.ll (diff)
Commit 39ff002e526e1df3e4bebbfdd2beebf0440d7d92 by steveire
[ASTMatchers] Clarify example in docs
The file was modifiedclang/docs/LibASTMatchersReference.html (diff)
Commit 5f3c99085d4c2ebf57fd0586b013b02e32a8e20b by aqjune
[ValueTracking] Dereferenced pointers are noundef

This is a follow-up of D95238's LangRef update.
This patch updates `programUndefinedIfUndefOrPoison(V)` to return true if
`V` is used by any memory-accessing instruction.
Interestingly, this affected many tests in Attributors, mainly about adding noundefs.
The tests are updated using llvm/utils/update_test_checks.py. I checked that the diffs
are about updating noundefs.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D96642
The file was modifiedllvm/test/Transforms/Attributor/misc_crash.ll (diff)
The file was modifiedllvm/test/Transforms/Attributor/internal-noalias.ll (diff)
The file was modifiedllvm/test/Transforms/Attributor/liveness.ll (diff)
The file was modifiedllvm/test/Transforms/Attributor/ArgumentPromotion/byval-2.ll (diff)
The file was modifiedllvm/test/Transforms/Attributor/nonnull.ll (diff)
The file was modifiedllvm/test/Transforms/Attributor/range.ll (diff)
The file was modifiedllvm/test/Transforms/OpenMP/parallel_deletion.ll (diff)
The file was modifiedllvm/test/Transforms/Attributor/read_write_returned_arguments_scc.ll (diff)
The file was modifiedllvm/test/Transforms/Attributor/misc.ll (diff)
The file was modifiedllvm/test/Transforms/Attributor/dereferenceable-1.ll (diff)
The file was modifiedllvm/test/Transforms/Attributor/nosync.ll (diff)
The file was modifiedllvm/test/Transforms/Attributor/ArgumentPromotion/attrs.ll (diff)
The file was modifiedllvm/include/llvm/Analysis/ValueTracking.h (diff)
The file was modifiedllvm/test/Transforms/Attributor/depgraph.ll (diff)
The file was modifiedllvm/test/Transforms/Attributor/nocapture-2.ll (diff)
The file was modifiedllvm/test/Transforms/Attributor/heap_to_stack.ll (diff)
The file was modifiedllvm/test/Transforms/Attributor/undefined_behavior.ll (diff)
The file was modifiedllvm/test/Transforms/Attributor/nofree.ll (diff)
The file was modifiedllvm/test/Transforms/Attributor/memory_locations.ll (diff)
The file was modifiedllvm/test/Transforms/Attributor/ArgumentPromotion/tail.ll (diff)
The file was modifiedllvm/test/Transforms/Attributor/norecurse.ll (diff)
The file was modifiedllvm/test/Transforms/Attributor/ArgumentPromotion/X86/attributes.ll (diff)
The file was modifiedllvm/test/Transforms/Attributor/value-simplify.ll (diff)
The file was modifiedllvm/test/Transforms/InstSimplify/freeze.ll (diff)
The file was modifiedllvm/test/Transforms/Attributor/nocapture-1.ll (diff)
The file was modifiedllvm/test/Transforms/Attributor/ArgumentPromotion/X86/min-legal-vector-width.ll (diff)
The file was modifiedllvm/test/Transforms/Attributor/align.ll (diff)
The file was modifiedllvm/test/Transforms/Attributor/dereferenceable-2.ll (diff)
The file was modifiedllvm/test/Transforms/Attributor/ArgumentPromotion/dbg.ll (diff)
The file was modifiedllvm/test/Transforms/Attributor/dereferenceable-2-inseltpoison.ll (diff)
The file was modifiedllvm/test/Transforms/Attributor/readattrs.ll (diff)
The file was modifiedllvm/test/Transforms/Attributor/ArgumentPromotion/2008-07-02-array-indexing.ll (diff)
The file was modifiedllvm/lib/Analysis/ValueTracking.cpp (diff)
The file was modifiedllvm/test/Transforms/Attributor/chain.ll (diff)
The file was modifiedllvm/test/Transforms/Attributor/callbacks.ll (diff)
The file was modifiedllvm/test/Transforms/Attributor/noalias.ll (diff)
Commit 428bc6feed088accf549296b77ecf544d54ff1c9 by nicolas.vasilache
[mlir][Linalg] Fix constant detection in linalg.pad_tensor vectorization.
The file was modifiedmlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp (diff)
The file was modifiedmlir/test/Dialect/Linalg/vectorization.mlir (diff)
Commit 728803ed74e26b370600002dcffe4994ce3ec37a by nikita.ppv
[BasicAA] Use index difference to detect GEPs with identical indexes

We currently detect GEPs that have exactly the same indexes by
comparing the Offsets and VarIndices. However, the latter implicitly
performs equality comparisons between two values, which is not
generally legal inside BasicAA, due to the possibility of comparisons
across phi cycles.

I believe that in this particular instance this actually ends up being
unproblematic, at least I wasn't able to come up with any cases that
could result in an incorrect root query result.

In the interest of being defensive, compute GetIndexDifference earlier
(which knows how to handle phi cycles properly) and use the result of
that to determine whether the offsets are identical.
The file was modifiedllvm/lib/Analysis/BasicAliasAnalysis.cpp (diff)
The file was modifiedllvm/include/llvm/Analysis/BasicAliasAnalysis.h (diff)
Commit 53ae96d4bb4976c458b5c50e00782980efba9ded by nikita.ppv
[BasicAA] Avoid duplicate query for GEPs with identical offsets (NFCI)

For two GEPs with identical offsets, we currently first perform
a base address query without size information, and then if it is
MayAlias, perform another with size information. This is pointless,
as the latter query should produce strictly better results.

This was not quite true historically due to the way that NoAlias
assumptions were handled, but that issue has since been resolved.
The file was modifiedllvm/lib/Analysis/BasicAliasAnalysis.cpp (diff)
Commit 6ac12e4b348cd954f0c0dea8a026b863416849fa by kazu
[Analysis] Use ListSeparator (NFC)
The file was modifiedllvm/lib/Analysis/SyncDependenceAnalysis.cpp (diff)
Commit 1cc558bd4fa1acd1462226ef4796c712f80ea8e8 by kazu
[llvm] Fix header guards (NFC)

Identified with llvm-header-guard.
The file was modifiedllvm/include/llvm/Analysis/ObjCARCUtil.h (diff)
The file was modifiedllvm/include/llvm/CodeGen/ReplaceWithVeclib.h (diff)
Commit 910e2d1e57b78c0a2fa77a490eb1e1d55bfba6f4 by kazu
[llvm] Use llvm::is_contained (NFC)
The file was modifiedllvm/lib/TableGen/Record.cpp (diff)
The file was modifiedllvm/lib/Target/Hexagon/HexagonHardwareLoops.cpp (diff)
The file was modifiedllvm/lib/CodeGen/MachineVerifier.cpp (diff)
The file was modifiedllvm/tools/opt/opt.cpp (diff)
The file was modifiedllvm/include/llvm/TableGen/Record.h (diff)
The file was modifiedllvm/include/llvm/IR/DataLayout.h (diff)
The file was modifiedllvm/lib/Target/AMDGPU/AMDGPUMachineCFGStructurizer.cpp (diff)
The file was modifiedllvm/lib/Passes/StandardInstrumentations.cpp (diff)
The file was modifiedllvm/lib/Object/IRSymtab.cpp (diff)
The file was modifiedllvm/lib/Analysis/AssumeBundleQueries.cpp (diff)
The file was modifiedllvm/lib/CodeGen/MachineModuleInfo.cpp (diff)
The file was modifiedllvm/lib/Transforms/IPO/ArgumentPromotion.cpp (diff)
The file was modifiedllvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp (diff)
The file was modifiedllvm/tools/llvm-xray/xray-graph-diff.cpp (diff)
The file was modifiedllvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp (diff)
The file was modifiedllvm/lib/Target/Mips/MipsLegalizerInfo.cpp (diff)
The file was modifiedllvm/lib/Target/X86/X86SelectionDAGInfo.cpp (diff)
The file was modifiedllvm/lib/Transforms/Utils/BasicBlockUtils.cpp (diff)
The file was modifiedllvm/lib/Analysis/LoopInfo.cpp (diff)