History log of /llvm-project/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp (Results 301 – 325 of 549)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: llvmorg-4.0.1-rc2
# 8205a1a9 24-May-2017 Craig Topper <craig.topper@gmail.com>

[ValueTracking] Convert most of the calls to computeKnownBits to use the version that returns the KnownBits object.

This continues the changes started when computeSignBit was replaced with this new

[ValueTracking] Convert most of the calls to computeKnownBits to use the version that returns the KnownBits object.

This continues the changes started when computeSignBit was replaced with this new version of computeKnowBits.

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

llvm-svn: 303773

show more ...


# 21a49dcd 21-May-2017 Davide Italiano <davide@freebsd.org>

[InstCombine] Take in account the size in sext->lshr->trunc patterns.

Otherwise we end up miscompiling, transforming:

define i8 @tinky() {
%sext = sext i1 1 to i16
%hibit = lshr i16 %sext, 15

[InstCombine] Take in account the size in sext->lshr->trunc patterns.

Otherwise we end up miscompiling, transforming:

define i8 @tinky() {
%sext = sext i1 1 to i16
%hibit = lshr i16 %sext, 15
%tr = trunc i16 %hibit to i8
ret i8 %tr
}

into:

%sext = sext i1 1 to i8
ret i8 %sext

and the first get folded to ret i8 1, while the second gets folded
to ret i8 -1.

Eventually we should get rid of this transform entirely, but for now,
this at least fixes a know correctness bug.

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

llvm-svn: 303513

show more ...


# 1a36b7d8 15-May-2017 Craig Topper <craig.topper@gmail.com>

[ValueTracking] Replace all uses of ComputeSignBit with computeKnownBits.

This patch finishes off the conversion of ComputeSignBit to computeKnownBits.

Differential Revision: https://reviews.llvm.o

[ValueTracking] Replace all uses of ComputeSignBit with computeKnownBits.

This patch finishes off the conversion of ComputeSignBit to computeKnownBits.

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

llvm-svn: 303035

show more ...


# 6844e21f 09-May-2017 Sanjay Patel <spatel@rotateright.com>

[InstCombineCasts] Fix checks in sext->lshr->trunc pattern.

The comment says to avoid the case where zero bits are shifted into the truncated value,
but the code checks that the shift is smaller th

[InstCombineCasts] Fix checks in sext->lshr->trunc pattern.

The comment says to avoid the case where zero bits are shifted into the truncated value,
but the code checks that the shift is smaller than the truncated value instead of the
number of bits added by the sign extension. Fixing this allows a shift by more than the
value size to be introduced, which is undefined behavior, so the shift is capped at the
value size minus one, which has the expected behavior of filling the value with the sign
bit.

Patch by Jacob Young!

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

llvm-svn: 302548

show more ...


Revision tags: llvmorg-4.0.1-rc1
# b45eabcf 26-Apr-2017 Craig Topper <craig.topper@gmail.com>

[ValueTracking] Introduce a KnownBits struct to wrap the two APInts for computeKnownBits

This patch introduces a new KnownBits struct that wraps the two APInt used by computeKnownBits. This allows u

[ValueTracking] Introduce a KnownBits struct to wrap the two APInts for computeKnownBits

This patch introduces a new KnownBits struct that wraps the two APInt used by computeKnownBits. This allows us to treat them as more of a unit.

Initially I've just altered the signatures of computeKnownBits and InstCombine's simplifyDemandedBits to pass a KnownBits reference instead of two separate APInt references. I'll do similar to the SelectionDAG version of computeKnownBits/simplifyDemandedBits as a separate patch.

I've added a constructor that allows initializing both APInts to the same bit width with a starting value of 0. This reduces the repeated pattern of initializing both APInts. Once place default constructed the APInts so I added a default constructor for those cases.

Going forward I would like to add more methods that will work on the pairs. For example trunc, zext, and sext occur on both APInts together in several places. We should probably add a clear method that can be used to clear both pieces. Maybe a method to check for conflicting information. A method to return (Zero|One) so we don't write it out everywhere. Maybe a method for (Zero|One).isAllOnesValue() to determine if all bits are known. I'm sure there are many other methods we can come up with.

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

llvm-svn: 301432

show more ...


# f09c1e34 18-Apr-2017 Sanjoy Das <sanjoy@playingwithpointers.com>

Add a getPointerOperandType() helper to LoadInst and StoreInst; NFC

I will use this in a later change.

llvm-svn: 300613


# fb71b7d3 14-Apr-2017 Craig Topper <craig.topper@gmail.com>

[InstCombine] Support folding a subtract with a constant LHS into a phi node

We currently only support folding a subtract into a select but not a PHI. This fixes that.

I had to fix an assumption in

[InstCombine] Support folding a subtract with a constant LHS into a phi node

We currently only support folding a subtract into a select but not a PHI. This fixes that.

I had to fix an assumption in FoldOpIntoPhi that assumed the PHI node was always in operand 0. Now we pass it in like we do for FoldOpIntoSelect. But we still require some dancing to find the Constant when we create the BinOp or ConstantExpr. This is based code is similar to what we do for selects.

Since I touched all call sites, this also renames FoldOpIntoPhi to foldOpIntoPhi to match coding standards.

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

llvm-svn: 300363

show more ...


# 6b00d409 20-Mar-2017 Matt Arsenault <Matthew.Arsenault@amd.com>

InstCombine: Check source value precision when reducing cast intrinsic

Missed this check when porting from the libcall version.

llvm-svn: 298312


# c98dabb1 16-Mar-2017 Bjorn Pettersson <bjorn.a.pettersson@ericsson.com>

[InstCombine] Liberate assert in InstCombiner::visitZExt

Summary:
The call to canEvaluateZExtd in InstCombiner::visitZExt may
return with BitsToClear == SrcTy->getScalarSizeInBits(), but
there is an

[InstCombine] Liberate assert in InstCombiner::visitZExt

Summary:
The call to canEvaluateZExtd in InstCombiner::visitZExt may
return with BitsToClear == SrcTy->getScalarSizeInBits(), but
there is an assert that BitsToClear should be smaller than
SrcTy->getScalarSizeInBits().

I have a test case that triggers the assert, but it only happens
for my downstream target. I've not been able to trigger it for
any upstream target.

The assert triggered for a piece of code such as this
%shr1 = lshr i16 undef, 15
...
%shr2 = lshr i16 %shr1, 1
%conv = zext i16 %shr2 to i32

Normally the lshr instructions are constant folded before we
visit the zext (that is why it is so hard to reproduce).
The original pattern, before instcombine, is of course a lot more
complicated in my test case. The shift count in the second lshr
is for example determined by the outcome of a PHI instruction.
It seems like other rewrites by instcombine leads up to
the pattern above. And then the zext is pulled from the
worklist, and visited (hitting the assert), before we detect
that the lshr instrucions can be constant folded.

Anyway, since the canEvaluateZExtd may return with BitsToClear
equal to SrcTy->getScalarSizeInBits(), and since the rewrite
that converts the expression type to avoid a zero extend works
also for the case where SrcBitsKept ends up being zero, then
it should be OK to liberate the assert to
assert(BitsToClear <= SrcTy->getScalarSizeInBits() &&
"Unreasonable BitsToClear");

Reviewers: hfinkel

Reviewed By: hfinkel

Subscribers: hfinkel, llvm-commits

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

llvm-svn: 297952

show more ...


# 62906af3 08-Mar-2017 Sanjay Patel <spatel@rotateright.com>

[InstCombine] avoid crashing on shuffle shrinkage when input type is not same as result type

llvm-svn: 297280


# fe970514 07-Mar-2017 Sanjay Patel <spatel@rotateright.com>

[InstCombine] shrink truncated insertelement into undef vector

This is the 2nd part of solving:
http://lists.llvm.org/pipermail/llvm-dev/2017-February/110293.html

D30123 moves the trunc ahead of th

[InstCombine] shrink truncated insertelement into undef vector

This is the 2nd part of solving:
http://lists.llvm.org/pipermail/llvm-dev/2017-February/110293.html

D30123 moves the trunc ahead of the shuffle, and this moves the trunc ahead of the insertelement.
We're limiting this transform to undef rather than any constant to avoid backend problems.

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

llvm-svn: 297242

show more ...


# 53fa17a0 07-Mar-2017 Sanjay Patel <spatel@rotateright.com>

[InstCombine] shrink truncated splat shuffle (2nd try)

This was committed at r297155 and reverted at r297166 because of an
over-reaching clang test. That should be fixed with r297189.

This is one p

[InstCombine] shrink truncated splat shuffle (2nd try)

This was committed at r297155 and reverted at r297166 because of an
over-reaching clang test. That should be fixed with r297189.

This is one part of solving a recent bug report:
http://lists.llvm.org/pipermail/llvm-dev/2017-February/110293.html

This keeps with our general approach: changing arbitrary shuffles is off-limts,
but changing splat is ok. The transform is very similar to the existing
shrinkBitwiseLogic() canonicalization.

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

llvm-svn: 297232

show more ...


Revision tags: llvmorg-4.0.0, llvmorg-4.0.0-rc4
# 6d306061 07-Mar-2017 Sanjay Patel <spatel@rotateright.com>

revert r297155 because there's a clang test that depends on InstCombine:

tools/clang/test/CodeGen/zvector.c

llvm-svn: 297166


# defdb7be 07-Mar-2017 Sanjay Patel <spatel@rotateright.com>

[InstCombine] shrink truncated splat shuffle

This is one part of solving a recent bug report:
http://lists.llvm.org/pipermail/llvm-dev/2017-February/110293.html

This keeps with our general approach

[InstCombine] shrink truncated splat shuffle

This is one part of solving a recent bug report:
http://lists.llvm.org/pipermail/llvm-dev/2017-February/110293.html

This keeps with our general approach: changing arbitrary shuffles is off-limts,
but changing splat is ok. The transform is very similar to the existing
shrinkBitwiseLogic() canonicalization.

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

llvm-svn: 297155

show more ...


Revision tags: llvmorg-4.0.0-rc3
# ec9a8de0 24-Feb-2017 Sanjay Patel <spatel@rotateright.com>

[InstCombine] don't try SimplifyDemandedInstructionBits from zext/sext because it's slow and unnecessary

This one seems more obvious than D30270 that it can't make improvements because an extension

[InstCombine] don't try SimplifyDemandedInstructionBits from zext/sext because it's slow and unnecessary

This one seems more obvious than D30270 that it can't make improvements because an extension always needs
all of the incoming bits. There's one specific transform in SimplifyDemandedInstructionBits of converting
a sext to a zext when the sign-bit is known zero, but that is handled explicitly in visitSext() with
ComputeSignBit().

Like D30270, there are no IR differences (other than instruction names) for the case in PR32037:
https://bugs.llvm.org//show_bug.cgi?id=32037
...and no regression test differences.

Zext/sext are a smaller part of the profile, but this still appears to shave off another 0.5% or so from
'opt -O2'.

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

llvm-svn: 296129

show more ...


# 68e4cb3c 23-Feb-2017 Sanjay Patel <spatel@rotateright.com>

[InstCombine] use loop instead of recursion to peek through FPExt; NFCI

llvm-svn: 295992


# adf2ab16 23-Feb-2017 Sanjay Patel <spatel@rotateright.com>

[InstCombine] use 'match' to reduce code; NFCI

llvm-svn: 295991


Revision tags: llvmorg-4.0.0-rc2
# 2217f75a 31-Jan-2017 Sanjay Patel <spatel@rotateright.com>

fix formatting; NFC

llvm-svn: 293652


# 954a624f 23-Jan-2017 Matt Arsenault <Matthew.Arsenault@amd.com>

SimplifyLibCalls: Replace more unary libcalls with intrinsics

llvm-svn: 292855


Revision tags: llvmorg-4.0.0-rc1
# 7233344c 17-Jan-2017 Matt Arsenault <Matthew.Arsenault@amd.com>

SimplifyLibCalls: Replace fabs libcalls with intrinsics

Add missing fabs(fpext) optimzation that worked with the call,
and also fixes it creating a second fpext when there were multiple
uses.

llvm-

SimplifyLibCalls: Replace fabs libcalls with intrinsics

Add missing fabs(fpext) optimzation that worked with the call,
and also fixes it creating a second fpext when there were multiple
uses.

llvm-svn: 292172

show more ...


# 17c7f703 14-Dec-2016 Stephan Bergmann <sbergman@redhat.com>

Replace APFloatBase static fltSemantics data members with getter functions

At least the plugin used by the LibreOffice build
(<https://wiki.documentfoundation.org/Development/Clang_plugins>) indirec

Replace APFloatBase static fltSemantics data members with getter functions

At least the plugin used by the LibreOffice build
(<https://wiki.documentfoundation.org/Development/Clang_plugins>) indirectly
uses those members (through inline functions in LLVM/Clang include files in turn
using them), but they are not exported by utils/extract_symbols.py on Windows,
and accessing data across DLL/EXE boundaries on Windows is generally
problematic.

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

llvm-svn: 289647

show more ...


Revision tags: llvmorg-3.9.1, llvmorg-3.9.1-rc3
# b7f8cb69 03-Dec-2016 Sanjay Patel <spatel@rotateright.com>

[InstCombine] change select type to eliminate bitcasts

This solves a secondary problem seen in PR6137:
https://llvm.org/bugs/show_bug.cgi?id=6137#c6

This is similar to the bitwise logic op fold add

[InstCombine] change select type to eliminate bitcasts

This solves a secondary problem seen in PR6137:
https://llvm.org/bugs/show_bug.cgi?id=6137#c6

This is similar to the bitwise logic op fold added with:
https://reviews.llvm.org/rL287707

And like that patch, I'm artificially restricting the
transform from vector <-> scalar types until we're sure
that the backend can handle that.

llvm-svn: 288584

show more ...


Revision tags: llvmorg-3.9.1-rc2
# aa8b28e5 30-Nov-2016 Sanjay Patel <spatel@rotateright.com>

[InstCombine] allow more narrowing transforms for logic ops

We had a limited version of this for scalar 'and'; this expands
the transform to 'or' and 'xor' and allows vectors types too.

llvm-svn: 2

[InstCombine] allow more narrowing transforms for logic ops

We had a limited version of this for scalar 'and'; this expands
the transform to 'or' and 'xor' and allows vectors types too.

llvm-svn: 288273

show more ...


Revision tags: llvmorg-3.9.1-rc1
# 1e6ca44a 22-Nov-2016 Sanjay Patel <spatel@rotateright.com>

add and use isBitwiseLogicOp() helper function; NFCI

llvm-svn: 287712


# e359eaaf 22-Nov-2016 Sanjay Patel <spatel@rotateright.com>

[InstCombine] change bitwise logic type to eliminate bitcasts

In PR27925:
https://llvm.org/bugs/show_bug.cgi?id=27925

...we proposed adding this fold to eliminate a bitcast. In D20774, there was
s

[InstCombine] change bitwise logic type to eliminate bitcasts

In PR27925:
https://llvm.org/bugs/show_bug.cgi?id=27925

...we proposed adding this fold to eliminate a bitcast. In D20774, there was
some concern about changing the type of a bitwise op as well as creating
bitcasts that might not be free for a target. However, if we're strictly
eliminating an instruction (by limiting this to one-use ops), then we should
be able to do this in InstCombine.

But we're cautiously restricting the transform for now to vector types to
avoid possible backend problems. A transform to make sure the logic op is
legal for the target should be added to reverse this transform and improve
codegen.

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

llvm-svn: 287707

show more ...


1...<<11121314151617181920>>...22