llvm/lib
Sanjay Patel 76b12c4bf0 [InstCombine] transform bitcasted bitwise logic ops with constants (PR26702)
Given that we're not actually reducing the instruction count in the included
regression tests, I think we would call this a canonicalization step.

The motivation comes from the example in PR26702:
https://llvm.org/bugs/show_bug.cgi?id=26702

If we hoist the bitwise logic ahead of the bitcast, the previously unoptimizable
example of:

define <4 x i32> @is_negative(<4 x i32> %x) {
  %lobit = ashr <4 x i32> %x, <i32 31, i32 31, i32 31, i32 31>
  %not = xor <4 x i32> %lobit, <i32 -1, i32 -1, i32 -1, i32 -1>
  %bc = bitcast <4 x i32> %not to <2 x i64>
  %notnot = xor <2 x i64> %bc, <i64 -1, i64 -1>
  %bc2 = bitcast <2 x i64> %notnot to <4 x i32>
  ret <4 x i32> %bc2
}

Simplifies to the expected:

define <4 x i32> @is_negative(<4 x i32> %x) {
  %lobit = ashr <4 x i32> %x, <i32 31, i32 31, i32 31, i32 31>
  ret <4 x i32> %lobit
}

Differential Revision: http://reviews.llvm.org/D17583



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@262645 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-03 19:19:04 +00:00
..
Analysis Fix breakage caused by r262636. 2016-03-03 18:53:20 +00:00
AsmParser [AVR] Add calling convention parser tokens 2016-03-03 10:08:02 +00:00
Bitcode [ThinLTO] Add missing breaks when parsing summaries (NFC) 2016-02-24 17:57:28 +00:00
CodeGen [X86][SSE] Improve vector ZERO_EXTEND by combining to ZERO_EXTEND_VECTOR_INREG 2016-03-03 09:43:28 +00:00
DebugInfo [DebugInfo] Dump CIE augmentation data as a list of hex bytes 2016-03-01 18:38:05 +00:00
ExecutionEngine Refactor duplicated code for linking with pthread. 2016-03-01 15:54:40 +00:00
Fuzzer [libFuzzer] add -Werror for libFuzzer build rule 2016-03-02 21:08:16 +00:00
IR [ConstantRange] Generalize makeGuaranteedNoWrapRegion to work on ranges 2016-03-03 18:31:16 +00:00
IRReader Remove autoconf support 2016-01-26 21:29:08 +00:00
LibDriver Remove autoconf support 2016-01-26 21:29:08 +00:00
LineEditor Remove autoconf support 2016-01-26 21:29:08 +00:00
Linker Pass a std::unique_ptr to IRMover::move. 2016-02-16 18:50:12 +00:00
LTO Fix some warnings a bit harder/different 2016-03-01 20:41:17 +00:00
MC [lanai] Add ELF enum value and relocations. 2016-03-01 21:21:42 +00:00
Object [lanai] Add ELF enum value and relocations. 2016-03-01 21:21:42 +00:00
ObjectYAML Add LLVMBuild for ObjectYAML. 2016-03-01 21:29:33 +00:00
Option Annotate dump() methods with LLVM_DUMP_METHOD, addressing Richard Smith r259192 post commit comment. 2016-01-29 20:50:44 +00:00
Passes [PM] Wire up optimization levels and default pipeline construction APIs 2016-02-28 22:16:03 +00:00
ProfileData Use LineLocation instead of CallsiteLocation to index callsite profile. 2016-03-03 18:09:32 +00:00
Support Refactor duplicated code for linking with pthread. 2016-03-01 15:54:40 +00:00
TableGen [TableGen] Fix typos in comments. NFC 2016-02-26 06:50:27 +00:00
Target [X86][AVX] Better support for the variable mask form of VPERMILPD/VPERMILPS 2016-03-03 18:13:53 +00:00
Transforms [InstCombine] transform bitcasted bitwise logic ops with constants (PR26702) 2016-03-03 19:19:04 +00:00
CMakeLists.txt Move ObjectYAML code to a new library. 2016-03-01 19:15:06 +00:00
LLVMBuild.txt Add LLVMBuild for ObjectYAML. 2016-03-01 21:29:33 +00:00