llvm/lib/Transforms/InstCombine
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
..
CMakeLists.txt Use ADDITIONAL_HEADER_DIRS in all LLVM CMake projects. 2015-02-11 03:28:02 +00:00
InstCombineAddSub.cpp Remove uses of builtin comma operator. 2016-02-18 22:09:30 +00:00
InstCombineAndOrXor.cpp [InstCombine] transform bitcasted bitwise logic ops with constants (PR26702) 2016-03-03 19:19:04 +00:00
InstCombineCalls.cpp [x86, InstCombine] transform more x86 masked loads to LLVM intrinsics 2016-02-29 23:59:00 +00:00
InstCombineCasts.cpp revert r262424 because there's a *clang test* for AArch64 that checks -O3 asm output 2016-03-02 01:04:09 +00:00
InstCombineCompares.cpp Remove uses of builtin comma operator. 2016-02-18 22:09:30 +00:00
InstCombineInternal.h [InstCombine] add helper function to foldCastedBitwiseLogic() ; NFCI 2016-02-23 16:36:07 +00:00
InstCombineLoadStoreAlloca.cpp Explode store of arrays in instcombine 2016-03-02 22:36:45 +00:00
InstCombineMulDivRem.cpp Remove uses of builtin comma operator. 2016-02-18 22:09:30 +00:00
InstCombinePHI.cpp Fixed typo in r260530 2016-02-11 16:46:13 +00:00
InstCombineSelect.cpp function names start with a lowercase letter; NFC 2016-02-01 22:23:39 +00:00
InstCombineShifts.cpp function names start with a lowercase letter; NFC 2016-02-01 22:23:39 +00:00
InstCombineSimplifyDemanded.cpp function names start with a lowercase letter; NFC 2016-02-01 22:23:39 +00:00
InstCombineVectorOps.cpp Fix an issue where fast math flags were dropped during scalarization. 2016-03-01 19:35:52 +00:00
InstructionCombining.cpp Perform InstructioinCombiningPass before SampleProfile pass. 2016-03-01 22:53:02 +00:00
LLVMBuild.txt Update libdeps since TLI was moved from Target to Analysis in r226078. 2015-01-15 05:21:00 +00:00