llvm-project/llvm/test
Sanjay Patel a41c886c55 [DAGCombiner] extend(ifpositive(X)) -> shift-right (not X)
This is almost the same as an existing IR canonicalization in instcombine, 
so I'm assuming this is a good early generic DAG combine too.

The motivation comes from reduced bit-hacking for select-of-constants in IR 
after rL331486. We want to restore that functionality in the DAG as noted in
the commit comments for that change and the llvm-dev discussion here:
http://lists.llvm.org/pipermail/llvm-dev/2018-July/124433.html

The PPC and AArch tests show that those targets are already doing something 
similar. x86 will be neutral in the minimal case and generally better when 
this pattern is extended with other ops as shown in the signbit-shift.ll tests.

Note the asymmetry: we don't include the (extend (ifneg X)) transform because 
it already exists in SimplifySelectCC(), and that is verified in the later 
unchanged tests in the signbit-shift.ll files. Without the 'not' op, the 
general transform to use a shift is always a win because that's a single 
instruction.

Alive proofs:
https://rise4fun.com/Alive/ysli

Name: if pos, get -1
  %c = icmp sgt i16 %x, -1
  %r = sext i1 %c to i16
  =>
  %n = xor i16 %x, -1
  %r = ashr i16 %n, 15

Name: if pos, get 1
  %c = icmp sgt i16 %x, -1
  %r = zext i1 %c to i16
  =>
  %n = xor i16 %x, -1
  %r = lshr i16 %n, 15

Differential Revision: https://reviews.llvm.org/D48970

llvm-svn: 337130
2018-07-15 16:27:07 +00:00
..
Analysis Re-apply "[SCEV] Strengthen StrengthenNoWrapFlags (reapply r334428)." 2018-07-13 23:58:46 +00:00
Assembler [ThinLTO] Escape module paths when printing 2018-07-12 14:40:21 +00:00
Bindings
Bitcode [FileCheck] Add -allow-deprecated-dag-overlap to failing llvm tests 2018-07-11 20:25:49 +00:00
BugPoint
CodeGen [DAGCombiner] extend(ifpositive(X)) -> shift-right (not X) 2018-07-15 16:27:07 +00:00
DebugInfo [dwarfdump] Pretty print DW_AT_APPLE_runtime_class 2018-07-13 16:06:17 +00:00
Examples
ExecutionEngine Revert "Re-land r335297 "[X86] Implement more of x86-64 large and medium PIC code models"" 2018-06-28 17:56:43 +00:00
Feature
FileCheck [FileCheck] Implement -v and -vv for tracing matches 2018-07-13 03:08:23 +00:00
Instrumentation [FileCheck] Add -allow-deprecated-dag-overlap to failing llvm tests 2018-07-11 20:25:49 +00:00
Integer
JitListener
LTO [LTO] Fix linking with an alias defined using another alias. 2018-07-13 21:58:55 +00:00
Linker
MC [AArch64][SVE] Asm: Vector Unpack Low/High instructions. 2018-07-13 09:25:43 +00:00
Object [ELF] Change isSectionData to exclude SHF_EXECINSTR 2018-06-23 00:15:33 +00:00
ObjectYAML
Other IR: Skip -print-*-all after -print-* 2018-07-11 23:30:25 +00:00
SafepointIRVerifier
SymbolRewriter
TableGen [json, test] Fix the json.td test - the path to python could contain spaces 2018-07-13 15:10:53 +00:00
ThinLTO/X86 [LowerTypeTests] Limit when icall jumptable entries are emitted 2018-07-13 19:57:39 +00:00
Transforms [InstSimplify] add fixme comment for PR37776; NFC 2018-07-15 16:13:58 +00:00
Unit
Verifier Revert "Add support for generating a call graph profile from Branch Frequency Info." 2018-06-28 13:15:03 +00:00
YAMLParser
tools [llvm-mca] Regenerate X86 specific tests. NFC 2018-07-15 11:43:11 +00:00
.clang-format
CMakeLists.txt
TestRunner.sh
lit.cfg.py [LIT] Enable testing of LLVM gold plugin on Mac OS X 2018-06-20 15:32:47 +00:00
lit.site.cfg.py.in