555 Commits

Author SHA1 Message Date
Sanjay Patel
7706083ace [InstSimplify] fold srem with sext bool divisor
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335616 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-26 15:32:54 +00:00
Sanjay Patel
df0d594dd0 [InstSimplify] fold div/rem of zexted bool
I was looking at an unrelated fold and noticed that
we don't have this simplification (because the other
fold would break existing tests).

Name: zext udiv
  %z = zext i1 %x to i32
  %r = udiv i32 %y, %z
=>
  %r = %y

Name: zext urem
  %z = zext i1 %x to i32
  %r = urem i32 %y, %z
=>
  %r = 0

Name: zext sdiv
  %z = zext i1 %x to i32
  %r = sdiv i32 %y, %z
=>
  %r = %y

Name: zext srem
  %z = zext i1 %x to i32
  %r = srem i32 %y, %z
=>
  %r = 0

https://rise4fun.com/Alive/LZ9


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335512 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-25 18:51:21 +00:00
Sanjay Patel
0da71804c3 [InstSimplify] Fix missed optimization in simplifyUnsignedRangeCheck()
For both operands are unsigned, the following optimizations are valid, and missing:

   1. X > Y && X != 0 --> X > Y
   2. X > Y || X != 0 --> X != 0
   3. X <= Y || X != 0 --> true
   4. X <= Y || X == 0 --> X <= Y
   5. X > Y && X == 0 --> false

unsigned foo(unsigned x, unsigned y) { return x > y && x != 0; }
should fold to x > y, but I found we haven't done it right now.
besides, unsigned foo(unsigned x, unsigned y) { return x < y && y != 0; }
Has been folded to x < y, so there may be a bug.

Patch by: Li Jia He!

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335129 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-20 14:22:49 +00:00
Roman Lebedev
65cbabed5f [NFC][InstSimplify] SimplifyAddInst(): coding style: variable names.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334299 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-08 15:44:53 +00:00
Roman Lebedev
b76b2440ec [InstSimplify] add nuw %x, -1 -> -1 fold.
Summary:
`%ret = add nuw i8 %x, C`
From [[ https://llvm.org/docs/LangRef.html#add-instruction | langref ]]:
    nuw and nsw stand for “No Unsigned Wrap” and “No Signed Wrap”,
    respectively. If the nuw and/or nsw keywords are present,
    the result value of the add is a poison value if unsigned
    and/or signed overflow, respectively, occurs.

So if `C` is `-1`, `%x` can only be `0`, and the result is always `-1`.

I'm not sure we want to use `KnownBits`/`LVI` here, because there is
exactly one possible value (all bits set, `-1`), so some other pass
should take care of replacing the known-all-ones with constant `-1`.

The `test/Transforms/InstCombine/set-lowbits-mask-canonicalize.ll` change *is* confusing.
What happening is, before this: (omitting `nuw` for simplicity)
1. First, InstCombine D47428/rL334127 folds `shl i32 1, %NBits`) to `shl nuw i32 -1, %NBits`
2. Then, InstSimplify D47883/rL334222 folds `shl nuw i32 -1, %NBits` to `-1`,
3. `-1` is inverted to `0`.
But now:
1. *This* InstSimplify fold `%ret = add nuw i32 %setbit, -1` -> `-1` happens first,
   before InstCombine D47428/rL334127 fold could happen.
Thus we now end up with the opposite constant,
and it is all good: https://rise4fun.com/Alive/OA9

https://rise4fun.com/Alive/sldC
Was mentioned in D47428 review.
Follow-up for D47883.

Reviewers: spatel, craig.topper

Reviewed By: spatel

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334298 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-08 15:44:47 +00:00
Roman Lebedev
fa1dbcce5b [InstSimplify] shl nuw C, %x -> C iff signbit is set on C.
Summary:
`%r = shl nuw i8 C, %x`

As per langref:
```
If the nuw keyword is present, then the shift produces
a poison value if it shifts out any non-zero bits.
```
Thus, if the sign bit is set on `C`, then `%x` can only be `0`,
which means that `%r` can only be `C`.
Or in other words, set sign bit means that the signed value
is negative, so the constant is `<= 0`.

https://rise4fun.com/Alive/WMk
https://rise4fun.com/Alive/udv

Was mentioned in D47428 review.

We already handle the `0` constant, https://godbolt.org/g/UZq1sJ, so this only handles negative constants.

Could use computeKnownBits() / LazyValueInfo,
but the cost-benefit analysis (https://reviews.llvm.org/D47891)
suggests it isn't worth it.

Reviewers: spatel, craig.topper

Reviewed By: spatel

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334222 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-07 20:03:45 +00:00
Adrian Prantl
26b584c691 Remove \brief commands from doxygen comments.
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.

Patch produced by

  for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331272 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-01 15:54:18 +00:00
George Burgess IV
557491f34d Reland r301880(!): "[InstSimplify] Handle selects of GEPs with 0 offset"
I was reminded today that this patch got reverted in r301885. I can no
longer reproduce the failure that caused the revert locally (...almost
one year later), and the patch applied pretty cleanly, so I guess we'll
see if the bots still get angry about it.

The original breakage was InstSimplify complaining (in "assertion
failed" form) about getting passed some crazy IR when running `ninja
check-sanitizer`. I'm unable to find traces of what, exactly, said crazy
IR was. I suppose we'll find out pretty soon if that's still the case.
:)

Original commit:

  Author: gbiv
  Date: Mon May  1 18:12:08 2017
  New Revision: 301880

  URL: http://llvm.org/viewvc/llvm-project?rev=301880&view=rev
  Log:
  [InstSimplify] Handle selects of GEPs with 0 offset

  In particular (since it wouldn't fit nicely in the summary):
  (select (icmp eq V 0) P (getelementptr P V)) -> (getelementptr P V)

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330667 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-24 00:25:01 +00:00
Sanjay Patel
e1bbe84207 [PatternMatch] allow undef elements when matching a vector zero
This is the last step in getting constant pattern matchers to allow
undef elements in constant vectors.

I'm adding a dedicated m_ZeroInt() function and building m_Zero() from
that. In most cases, calling code can be updated to use m_ZeroInt()
directly when there's no need to match pointers, but I'm leaving that
efficiency optimization as a follow-up step because it's not always
clear when that's ok.

There are just enough icmp folds in InstSimplify that can be used for 
integer or pointer types, that we probably still want a generic m_Zero()
for those cases. Otherwise, we could eliminate it (and possibly add a
m_NullPtr() as an alias for isa<ConstantPointerNull>()).

We're conservatively returning a full zero vector (zeroinitializer) in
InstSimplify/InstCombine on some of these folds (see diffs in InstSimplify),
but I'm not sure if that's actually necessary in all cases. We may be 
able to propagate an undef lane instead. One test where this happens is 
marked with 'TODO'.
 


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330550 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-22 17:07:44 +00:00
Sanjay Patel
8eacad4a41 [InstSimplify] fix formatting; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329736 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-10 18:38:19 +00:00
Sanjay Patel
1017678677 [PatternMatch] allow undef elements when matching vector FP +0.0
This continues the FP constant pattern matching improvements from:
https://reviews.llvm.org/rL327627
https://reviews.llvm.org/rL327339
https://reviews.llvm.org/rL327307

Several integer constant matchers also have this ability. I'm
separating matching of integer/pointer null from FP positive zero
and renaming/commenting to make the functionality clearer.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@328461 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-25 21:16:33 +00:00
Sanjay Patel
3e65cc15a0 [InstSimplify] fp_binop X, NaN --> NaN
We propagate the existing NaN value when possible.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@328140 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-21 19:31:53 +00:00
Sanjay Patel
d65aba275a [InstSimplify] loosen FMF for sqrt(X) * sqrt(X) --> X
As shown in the code comment, we don't need all of 'fast', 
but we do need reassoc + nsz + nnan.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327796 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-18 14:12:25 +00:00
Roman Lebedev
73e0892707 [InstSimplify] peek through unsigned FP casts for sign-bit compares (PR36682)
This pattern came up in PR36682 / D44390
https://bugs.llvm.org/show_bug.cgi?id=36682
https://reviews.llvm.org/D44390
https://godbolt.org/g/oKvT5H

See also D44421, D44424

Reviewers: spatel, majnemer, efriedma, arsenm

Reviewed By: spatel

Subscribers: wdng, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327642 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-15 16:17:46 +00:00
Roman Lebedev
d2827a5a71 [InstSimplify][NFC] simplifyICmpWithConstant(): refactor GetCompareTy() calls
Preparation for D44425.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327641 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-15 16:17:40 +00:00
Matthew Simpson
828ff3b7ed [ConstantFolding, InstSimplify] Handle more vector GEPs
This patch addresses some additional cases where the compiler crashes upon
encountering vector GEPs. This should fix PR36116.

Differential Revision: https://reviews.llvm.org/D44219
Reference: https://bugs.llvm.org/show_bug.cgi?id=36116

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327638 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-15 16:00:29 +00:00
Sanjay Patel
e2ee2c948f [PatternMatch, InstSimplify] allow undef elements when matching any vector FP zero
This matcher implementation appears to be slightly more efficient than 
the generic constant check that it is replacing because every use was 
for matching FP patterns, but the previous code would check int and 
pointer type nulls too. 


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327627 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-15 14:29:27 +00:00
Sanjay Patel
175ecc9798 [InstSimplify] remove 'nsz' requirement for frem 0, X
From the LangRef definition for frem: 
"The value produced is the floating-point remainder of the two operands. 
This is the same output as a libm ‘fmod‘ function, but without any 
possibility of setting errno. The remainder has the same sign as the 
dividend. This instruction is assumed to execute in the default 
floating-point environment."


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327626 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-15 14:04:31 +00:00
Sanjay Patel
2a44ab0eda [InstSimplify] fix folds for (0.0 - X) + X --> 0 (PR27151)
As shown in:
https://bugs.llvm.org/show_bug.cgi?id=27151
...the existing fold could miscompile when X is NaN.

The fold was also dependent on 'ninf' but that's not necessary.

From IEEE-754 (with default rounding which we can assume for these opcodes):
"When the sum of two operands with opposite signs (or the difference of two 
operands with like signs) is exactly zero, the sign of that sum (or difference) 
shall be +0...However, x + x = x − (−x) retains the same sign as x even when 
x is zero."



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327575 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-14 21:23:27 +00:00
Sanjay Patel
253ee8cecf [InstSimplify] fp_binop X, undef --> NaN
The variable operand could be NaN, so it's always safe to propagate NaN.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327212 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-10 16:51:28 +00:00
Sanjay Patel
6ee3582153 [InstSimplify] remove redundant folds
The 'hasOneUse' check is a giveaway that something's not right.
We never need to check that in InstSimplify because we don't
create new instructions here.

These are all handled as icmp simplifies which then trigger
existing select simplifies, so there's no need to duplicate 
a composite fold of the two.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@326750 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-05 22:46:48 +00:00
Sanjay Patel
1629c23be7 [PatternMatch, InstSimplify] fix m_NaN to work with vector constants and use it
This is NFC for the moment (and independent of any potential NaN semantic
controversy). Besides making the code in InstSimplify easier to read, the
motivation is to eventually allow undef elements in vector constants to
match too. A proposal to add the base logic for that is in D43792.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@326600 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-02 18:36:08 +00:00
Sanjay Patel
4b957aaea8 [InstSimplify] sqrt(X) * sqrt(X) --> X
This was misplaced in InstCombine. We can loosen the FMF as a follow-up step.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@325965 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-23 22:20:13 +00:00
Sanjay Patel
5563781f3f [PatternMatch, InstSimplify] enhance m_AllOnes() to ignore undef elements in vectors
Loosening the matcher definition reveals a subtle bug in InstSimplify (we should not
assume that because an operand constant matches that it's safe to return it as a result).

So I'm making that change here too (that diff could be independent, but I'm not sure how 
to reveal it before the matcher change).

This also seems like a good reason to *not* include matchers that capture the value.
We don't want to encourage the potential misstep of propagating undef values when it's
not allowed/intended.

I didn't include the capture variant option here or in the related rL325437 (m_One), 
but it already exists for other constant matchers.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@325466 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-18 18:05:08 +00:00
Sanjay Patel
29a500dd45 [InstSimplify] move select undef cond fold with other constant cond folds; NFCI
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@325434 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-17 14:50:13 +00:00
Elena Demikhovsky
8e229ec0e5 Adding a width of the GEP index to the Data Layout.
Making a width of GEP Index, which is used for address calculation, to be one of the pointer properties in the Data Layout.
p[address space]:size:memory_size:alignment:pref_alignment:index_size_in_bits.
The index size parameter is optional, if not specified, it is equal to the pointer size.

Till now, the InstCombiner normalized GEPs and extended the Index operand to the pointer width.
It works fine if you can convert pointer to integer for address calculation and all registered targets do this.
But some ISAs have very restricted instruction set for the pointer calculation. During discussions were desided to retrieve information for GEP index from the Data Layout.
http://lists.llvm.org/pipermail/llvm-dev/2018-January/120416.html

I added an interface to the Data Layout and I changed the InstCombiner and some other passes to take the Index width into account.
This change does not affect any in-tree target. I added tests to cover data layouts with explicitly specified index size.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@325102 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-14 06:58:08 +00:00
Sanjay Patel
860eb48e1f [InstSimplify] allow exp/log simplifications with only 'reassoc' FMF
These intrinsic folds were added with D41381, but only allowed with isFast().
That's more than necessary because FMF has 'reassoc' to apply to these
kinds of folds after D39304, and that's all we need in these cases.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@324967 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-12 23:51:23 +00:00
Sanjay Patel
6d276fdd07 [InstSimplify] (X * Y) / Y --> X for relaxed floating-point ops
This is the FP counterpart that was mentioned in PR35709:
https://bugs.llvm.org/show_bug.cgi?id=35709

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@323716 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-30 00:18:37 +00:00
Zvi Rackover
f2b2f1fda3 InstSimplify: If divisor element is undef simplify to undef
Summary:
If any vector divisor element is undef, we can arbitrarily choose it be
zero which would make the div/rem an undef value by definition.

Reviewers: spatel, reames

Reviewed By: spatel

Subscribers: magabari, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@323343 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-24 17:22:00 +00:00
Anton Bikineev
a375f9297d [InstSimplify] (X << Y) % X -> 0
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@323182 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-23 09:27:47 +00:00
Sanjay Patel
b1b5a889fa [InstSimplify] use m_Specific and commutative matcher to reduce code; NFCI
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@322955 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-19 16:12:55 +00:00
Sanjay Patel
17f2d728b2 [InstSimplify] fix code comments; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@322456 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-14 15:58:18 +00:00
Sanjay Patel
72f9c7b293 [InstSimplify] fold implied null ptr check (PR35790)
This extends rL322327 to handle the pointer cast and should solve:
https://bugs.llvm.org/show_bug.cgi?id=35790

Name: or_eq_zero
  %isnull = icmp eq i64* %p, null
  %x = ptrtoint i64* %p to i64
  %somebits = and i64 %x, %y
  %somebits_are_zero = icmp eq i64 %somebits, 0
  %or = or i1 %somebits_are_zero, %isnull
  =>
  %or = %somebits_are_zero

Name: and_ne_zero
  %isnotnull = icmp ne i64* %p, null
  %x = ptrtoint i64* %p to i64
  %somebits = and i64 %x, %y
  %somebits_are_not_zero = icmp ne i64 %somebits, 0
  %and = and i1 %somebits_are_not_zero, %isnotnull
  =>
  %and = %somebits_are_not_zero

https://rise4fun.com/Alive/CQ3


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@322439 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-13 15:44:44 +00:00
Sanjay Patel
efa3fe9ab2 [InstSimplify] fold implied cmp with zero (PR35790)
This doesn't handle the more complicated case in the bug report yet:
https://bugs.llvm.org/show_bug.cgi?id=35790

For that, we have to match / look through a cast.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@322327 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-11 23:27:37 +00:00
Dmitry Venikov
0bb74a59ff [InstSimplify] Missed optimization in math expression: squashing exp(log), log(exp)
Summary: This patch enables folding following expressions under -ffast-math flag: exp(log(x)) -> x, exp2(log2(x)) -> x, log(exp(x)) -> x, log2(exp2(x)) -> x

Reviewers: spatel, hfinkel, davide

Reviewed By: spatel, hfinkel, davide

Subscribers: scanon, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321710 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-03 14:37:42 +00:00
Dmitry Venikov
9579686b84 Test commit
Reviewers: Quolyk

Reviewed By: Quolyk

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321636 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-02 05:47:42 +00:00
Philip Reames
186bdd656a [instsimplify] consistently handle undef and out of bound indices for insertelement and extractelement
In one case, we were handling out of bounds, but not undef indices.  In the other, we were handling undef (with the comment making the analogy to out of bounds), but not out of bounds.  Be consistent and treat both undef and constant out of bounds indices as producing undefined results.

As a side effect, this also protects instcombine from having to handle large constant indices as we always simplify first.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321575 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-30 05:54:22 +00:00
Philip Reames
89623b4cd2 Sink a couple of transforms from instcombine into instsimplify.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321467 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-27 01:14:30 +00:00
Philip Reames
028022a9f2 [NFC] Extract out a helper function for SimplifyCall(CS, Q)
This simplifies code, but the real motivation is that it lets me clean up some downstream code.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321466 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-27 00:16:12 +00:00
Simon Pilgrim
d94c9356e7 [InstSimplify] Check for in range extraction index before calling APInt::getZExtValue()
Reduced from oss-fuzz #4768 test case

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321454 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-26 11:42:39 +00:00
Zachary Turner
ece9b23b54 Fix many -Wsign-compare and -Wtautological-constant-compare warnings.
Most of the -Wsign-compare warnings are due to the fact that
enums are signed by default in the MS ABI, while the
tautological comparison warnings trigger on x86 builds where
sizeof(size_t) is 4 bytes, so N > numeric_limits<unsigned>::max()
is always false.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320750 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-14 22:07:03 +00:00
Michael Zolotukhin
0e973bcce6 Remove redundant includes from lib/Analysis.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320617 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-13 21:30:41 +00:00
Igor Laevsky
fcf12e077b Reintroduce r320049, r320014 and r319894.
OpenGL issues should be fixed by now.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320568 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-13 11:21:18 +00:00
Igor Laevsky
535b72d219 Revert r320049, r320014 and r319894
They were causing failures of the piglit OpenGL tests with AMD GPUs using the
Mesa radeonsi driver.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320466 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-12 10:03:39 +00:00
Zvi Rackover
138b4f2021 InstructionSimplify: 'extractelement' with an undef index is undef
Summary:
An undef extract index can be arbitrarily chosen to be an
out-of-range index value, which would result in the instruction being undef.

This change closes a gap identified while working on lowering vector permute intrinsics
with variable index vectors to pure LLVM IR.

Reviewers: arsenm, spatel, majnemer

Reviewed By: arsenm, spatel

Subscribers: fhahn, nhaehnle, wdng, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319910 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-06 17:51:46 +00:00
Igor Laevsky
3b06fccc77 [InstSimplify] Fold insertelement into undef if index is out of bounds
Differential Revision: https://reviews.llvm.org/D40650



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319894 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-06 14:04:45 +00:00
Florian Hahn
03c5509e66 [InstSimplify] More fcmp cases when comparing against negative constants.
Summary:
For known positive non-zero value X:
    fcmp uge X, -C => true
    fcmp ugt X, -C => true
    fcmp une X, -C => true
    fcmp oeq X, -C => false
    fcmp ole X, -C => false
    fcmp olt X, -C => false


Patch by Paul Walker.

Reviewers: majnemer, t.p.northover, spatel, RKSimon

Reviewed By: spatel

Subscribers: fhahn, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319538 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-01 12:34:16 +00:00
Sanjay Patel
52a381f749 [InstSimplify] use m_APFloat to simplify fcmp folds; NFCI
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319043 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-27 16:37:09 +00:00
Sanjay Patel
557e920ce8 [InstSimplify] fold and/or of fcmp ord/uno when operand is known nnan
The 'ord' and 'uno' predicates have a logic operation for NAN built into their definitions:

FCMP_ORD   =  7,  ///< 0 1 1 1    True if ordered (no nans)
FCMP_UNO   =  8,  ///< 1 0 0 0    True if unordered: isnan(X) | isnan(Y)

So we can simplify patterns like this:

(fcmp ord (known NNAN), X) && (fcmp ord X, Y) --> fcmp ord X, Y
(fcmp uno (known NNAN), X) || (fcmp uno X, Y) --> fcmp uno X, Y

It might be better to split this into (X uno 0) | (Y uno 0) as a canonicalization, but that
would be another patch.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@318627 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-19 15:34:27 +00:00
Adam Nemet
3b8950a6d6 Rename OptimizationDiagnosticInfo.* to OptimizationRemarkEmitter.*
Sync it up with the name of the class actually defined here.  This has been
bothering me for a while...

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315249 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-09 23:19:02 +00:00