llvm-project/llvm/lib
Jessica Paquette 96843d220d [AArch64][GlobalISel] Change G_ANYEXT fed by scalar G_ICMP to G_ZEXT
This is a common pattern:

```
    %icmp:_(s32) = G_ICMP intpred(eq), ...
    %ext:_(s64) = G_ANYEXT %icmp(s32)
    %and:_(s64) = G_AND %ext, 1
```

Here's an example: https://godbolt.org/z/T13f6o8zE

This pattern appears because of the following combine in the
LegalizationArtifactCombiner:

```
// zext(trunc x) - > and (aext/copy/trunc x), mask
```

Which kicks in when we widen the result of G_ICMP from 1 bit to 32 bits.

We know that, on AArch64, a scalar G_ICMP will produce 0 or 1. So the result
of `%ext` will always be 0 or 1 as well.

We have some KnownBits combines which eliminate redundant G_ANDs with masks.
These combines don't kick in with G_ANYEXT.

So, if we replace the G_ANYEXT with G_ZEXT in this situation, the KnownBits
based combines can remove the redundant G_AND.

I wasn't sure if it woud be more appropriate to

* Take this route
* Put this in the LegalizationArtifactCombiner.
* Allow 64 bit G_ICMP destinations

I decided on this route because

1) It's simple

2) I'm not sure if philosophically-speaking, we should be handling non-artifact
instructions + target-specific details like TargetBooleanContents in the
LegalizationArtifactCombiner

3) There is a lot of existing code which assumes we only have 32 bit G_ICMP
destinations. So, adding support for 64-bit destinations seems rather invasive
right now. I think that adding support for 64-bit destinations, or modelling
G_ICMP as ADDS/SUBS/etc is probably cleaner long term though.

This gives minor code size savings on all CTMark benchmarks.

Differential Revision: https://reviews.llvm.org/D110959
2021-10-01 15:01:20 -07:00
..
Analysis Revert "[LoopVectorize] Permit vectorisation of more select(cmp(), X, Y) reduction patterns" 2021-10-01 11:39:43 +02:00
AsmParser [ThinLTO] Add noRecurse and noUnwind thinlink function attribute propagation 2021-09-27 12:28:07 -07:00
BinaryFormat [llvm][clang][NFC] updates inline licence info 2021-08-11 02:48:53 +00:00
Bitcode [NFC][AttributeList] Replace index_begin/end with an iterator 2021-10-01 10:17:41 -07:00
Bitstream
CodeGen [DAG] scalarizeExtractedVectorLoad - replace getABITypeAlign with allowsMemoryAccess (PR45116) 2021-10-01 21:07:34 +01:00
DWARFLinker [dsymutil] Track incompleteness across unions 2021-09-24 14:26:37 -07:00
DWP [DWP] Refactoring llvm-dwp in to a library part 2 2021-07-22 14:23:29 -07:00
DebugInfo WIP: Verify -gsimple-template-names=mangled values 2021-09-24 14:28:18 -07:00
Demangle [Demangle][Rust] Parse non-ASCII identifiers 2021-10-01 22:08:32 +02:00
ExecutionEngine [ORC] Remove ORC RPC. 2021-10-01 11:17:33 -07:00
Extensions
FileCheck [FileCheck] Use StringRef for MatchRegexp to fix crash. 2021-09-01 14:27:14 +02:00
Frontend [openmp] Add addrspacecast to getOrCreateIdent 2021-09-30 21:36:31 +01:00
FuzzMutate [NewPM][FuzzMutate] Fix renaming 'unswitch' to 'simple-loop-unswitch' 2021-07-09 12:24:12 +02:00
Fuzzer
IR [NFC][AttributeList] Replace index_begin/end with an iterator 2021-10-01 10:17:41 -07:00
IRReader
InterfaceStub [llvm] Remove redundant calls to str() and c_str() (NFC) 2021-08-30 09:05:05 -07:00
LTO Revert "[LTO][Legacy] Add -debug-pass-manager option to enable pass run/skip trace." 2021-09-29 19:43:35 +00:00
LineEditor
Linker Copy Elementtype Attribute to IR at Link step 2021-09-07 11:41:43 -07:00
MC [SystemZ][z/OS] Introduce initial support for GOFF asm parser 2021-10-01 10:29:14 -04:00
MCA [MCA] Fix a warning 2021-09-20 09:46:38 -07:00
Object [AIX]implement the --syms and using "symbol index and qualname" for --sym --symbol--description for llvm-objdump for xcoff 2021-10-01 12:37:51 -04:00
ObjectYAML [llvm-objdump/llvm-readobj/obj2yaml/yaml2obj] Support STO_RISCV_VARIANT_CC and DT_RISCV_VARIANT_CC 2021-09-29 16:56:52 -07:00
Option [llvm/OptTable] Add named param comment for GroupedShortOption 2021-09-27 11:33:29 -04:00
Passes [BPI] Keep BPI available in loop passes through LoopStandardAnalysisResults 2021-09-30 10:27:05 -04:00
ProfileData [llvm][profile] Add padding after binary IDs 2021-09-28 11:50:50 -07:00
Remarks
Support [NFC] Restore magic and magicu to a globally visible location 2021-09-30 17:43:12 -07:00
TableGen [TableGen] Record::checkRecordAssertions() - Use const-ref iterator in for-range loop. NFCI. 2021-09-17 12:11:53 +01:00
Target [AArch64][GlobalISel] Change G_ANYEXT fed by scalar G_ICMP to G_ZEXT 2021-10-01 15:01:20 -07:00
Testing Fix for error "'Run' overrides a member function but is not marked 2021-06-11 06:56:00 -07:00
TextAPI [llvm] Use drop_begin (NFC) 2021-09-16 08:46:26 -07:00
ToolDrivers [OptTable] Rename PrintHelp to printHelp 2021-06-24 14:47:03 -07:00
Transforms [SimpleLoopUnswitch] Don't unswitch constant conditions 2021-10-01 21:30:54 +00:00
WindowsManifest Make WindowsManifestMerger::merge() take a MemoryBufferRef 2021-08-24 16:39:20 -04:00
XRay
CMakeLists.txt [DWP] Refactoring llvm-dwp in to a library part 2 2021-07-22 14:23:29 -07:00