1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-22 04:22:57 +02:00
llvm-mirror/lib/Transforms/InstCombine
Sanjay Patel 61ecb7fad2 [InstCombine] match De Morgan's Law hidden by zext ops (PR22723)
This is a fix for PR22723:
https://llvm.org/bugs/show_bug.cgi?id=22723

My first attempt at this was to change what I thought was the root problem:

xor (zext i1 X to i32), 1 --> zext (xor i1 X, true) to i32

...but we create the opposite pattern in InstCombiner::visitZExt(), so infinite loop!

My next idea was to fix the matchIfNot() implementation in PatternMatch, but that would
mean potentially returning a different size for the match than what was input. I think
this would require all users of m_Not to check the size of the returned match, so I 
abandoned that idea.

I settled on just fixing the exact case presented in the PR. This patch does allow the
2 functions in PR22723 to compile identically (x86):

bool test(bool x, bool y) { return !x | !y; }
bool test(bool x, bool y) { return !x || !y; }
...
andb	%sil, %dil
xorb	$1, %dil
movb	%dil, %al
retq

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

llvm-svn: 248634
2015-09-25 23:21:38 +00:00
..
CMakeLists.txt Use ADDITIONAL_HEADER_DIRS in all LLVM CMake projects. 2015-02-11 03:28:02 +00:00
InstCombineAddSub.cpp don't repeat function names in comments; NFC 2015-09-09 15:24:36 +00:00
InstCombineAndOrXor.cpp [InstCombine] match De Morgan's Law hidden by zext ops (PR22723) 2015-09-25 23:21:38 +00:00
InstCombineCalls.cpp [X86][SSE] Replace 128-bit SSE41 PMOVSX intrinsics with native IR 2015-09-23 08:48:33 +00:00
InstCombineCasts.cpp There is a trunc(lshr (zext A), Cst) optimization in InstCombineCasts that 2015-09-10 11:31:20 +00:00
InstCombineCompares.cpp [InstCombine] FoldICmpCstShrCst failed for ashr when comparing against -1 2015-09-19 00:48:31 +00:00
InstCombineInternal.h add ShouldChangeType() variant that takes bitwidths 2015-09-21 16:09:37 +00:00
InstCombineLoadStoreAlloca.cpp Clean up: Refactoring the hardcoded value of 6 for FindAvailableLoadedValue()'s parameter MaxInstsToScan. (Complete version of r247497. See D12886) 2015-09-18 19:14:35 +00:00
InstCombineMulDivRem.cpp don't repeat function names in comments; NFC 2015-09-09 15:24:36 +00:00
InstCombinePHI.cpp [InstCombine] Preserve metadata when merging loads that are phi 2015-09-23 18:40:57 +00:00
InstCombineSelect.cpp don't repeat function names in comments; NFC 2015-09-09 15:24:36 +00:00
InstCombineShifts.cpp Convert PHI getIncomingValue() to foreach over incoming_values(). NFC. 2015-05-12 20:05:31 +00:00
InstCombineSimplifyDemanded.cpp [InstCombine] Added vector demanded bits support for SSE4A EXTRQ/INSERTQ instructions 2015-09-17 20:32:45 +00:00
InstCombineVectorOps.cpp don't repeat function names in comments; NFC 2015-09-09 15:24:36 +00:00
InstructionCombining.cpp add ShouldChangeType() variant that takes bitwidths 2015-09-21 16:09:37 +00:00
LLVMBuild.txt Update libdeps since TLI was moved from Target to Analysis in r226078. 2015-01-15 05:21:00 +00:00
Makefile