llvm-project/llvm/lib
Dávid Bolvanský ed396212da [InstCombine] Transform abs pattern using multiplication to abs intrinsic (PR45691)
```
unsigned r(int v)
{
    return (1 | -(v < 0)) * v;
}

`r` is equivalent to `abs(v)`.

```

```
define <4 x i8> @src(<4 x i8> %0) {
%1:
  %2 = ashr <4 x i8> %0, { 31, undef, 31, 31 }
  %3 = or <4 x i8> %2, { 1, 1, 1, undef }
  %4 = mul nsw <4 x i8> %3, %0
  ret <4 x i8> %4
}
=>
define <4 x i8> @tgt(<4 x i8> %0) {
%1:
  %2 = icmp slt <4 x i8> %0, { 0, 0, 0, 0 }
  %3 = sub nsw <4 x i8> { 0, 0, 0, 0 }, %0
  %4 = select <4 x i1> %2, <4 x i8> %3, <4 x i8> %0
  ret <4 x i8> %4
}
Transformation seems to be correct!
```

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D94874
2021-01-17 17:06:14 +01:00
..
Analysis [InstSimplify] Fold x*C1/C2 <= x (PR48744) 2021-01-17 16:02:55 +01:00
AsmParser [X86] Add x86_amx type for intel AMX. 2020-12-30 13:52:13 +08:00
BinaryFormat [Debuginfo][DW_OP_implicit_pointer] (1/7) Support for DW_OP_LLVM_implicit_pointer 2021-01-15 14:45:04 +05:30
Bitcode [llvm] Use llvm::append_range (NFC) 2021-01-06 18:27:33 -08:00
Bitstream [llvm] Use llvm::append_range (NFC) 2021-01-06 18:27:33 -08:00
CodeGen [llvm] Use *::empty (NFC) 2021-01-16 09:40:55 -08:00
DWARFLinker [dsymutil] Add preliminary support for DWARF 5. 2021-01-12 21:55:41 -08:00
DebugInfo [PDB] Defer relocating .debug$S until commit time and parallelize it 2021-01-12 17:46:29 -08:00
Demangle [llvm] Remove redundant return and continue statements (NFC) 2021-01-14 20:30:34 -08:00
ExecutionEngine [Orc] Allow LLJITBuilder's CreateObjectLinkingLayer to return errors 2021-01-15 12:53:41 +01:00
Extensions llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
FileCheck [llvm] Remove redundant return and continue statements (NFC) 2021-01-14 20:30:34 -08:00
Frontend [OpenMPOpt][WIP] Expand parallel region merging 2021-01-11 08:06:23 -08:00
FuzzMutate llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
Fuzzer
IR [llvm] Construct SmallVector with iterator ranges (NFC) 2021-01-16 09:40:53 -08:00
IRReader static const char *const foo => const char foo[] 2020-12-01 10:33:18 -08:00
InterfaceStub [llvm-elfabi] Add flag to preserve timestamp when output is the same 2020-12-29 20:27:06 -08:00
LTO [LTO] Remove options to disable inlining, vectorization & GVNLoadPRE. 2021-01-16 16:29:15 +00:00
LineEditor llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
Linker [ExecutionEngine, Linker] Use erase_if (NFC) 2020-12-23 21:44:39 -08:00
MC Revert "[WebAssembly] MC layer writes table symbols to object files" 2021-01-15 15:50:22 -08:00
MCA [llvm] Use llvm::append_range (NFC) 2021-01-06 18:27:33 -08:00
Object [llvm] Use *::empty (NFC) 2021-01-16 09:40:55 -08:00
ObjectYAML [yaml2obj/obj2yaml] - Refine handling of SHT_GNU_verdef sections. 2021-01-15 12:40:42 +03:00
Option [llvm] Simplify string comparisons (NFC) 2021-01-11 18:48:09 -08:00
Passes [NewPM][Inliner] Move the 'always inliner' case in the same CGSCC pass as 'regular' inliner 2021-01-15 17:59:38 -08:00
ProfileData [llvm] Use llvm::append_range (NFC) 2021-01-06 18:27:33 -08:00
Remarks llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
Support [llvm] Remove redundant return and continue statements (NFC) 2021-01-14 20:30:34 -08:00
TableGen [TableGen] Enhance !cast<string> to handle bit and bits types. 2021-01-14 10:20:35 -05:00
Target [X86] Default to -x86-pad-for-align=false to drop assembler difference with or w/o -g 2021-01-16 16:39:54 -08:00
Testing [llvm][NFC] Remove unnecessary vector creation in Annotations 2020-11-14 15:55:09 +00:00
TextAPI [llvm] Remove redundant return and continue statements (NFC) 2021-01-14 20:30:34 -08:00
ToolDrivers llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
Transforms [InstCombine] Transform abs pattern using multiplication to abs intrinsic (PR45691) 2021-01-17 17:06:14 +01:00
WindowsManifest llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
XRay [lib/Object, tools] - Make ELFObjectFile::getELFFile return reference. 2020-12-04 16:02:29 +03:00
CMakeLists.txt llvmbuildectomy - support disabled native target 2020-11-13 15:50:13 +01:00