444 Commits

Author SHA1 Message Date
Sanjay Patel 5f8dac1929 [InstSimplify] fold shifts by sext bool
https://rise4fun.com/Alive/c3Y


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335633 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-26 17:31:38 +00:00
Sanjay Patel 84f6f2281a [InstSimplify] add tests for shifts by sext bool; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335631 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-26 17:15:07 +00:00
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 a301ecd20b [InstSimplify] add tests for srem with sext bool divisor; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335609 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-26 14:47:31 +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 e51396c3ae [InstSimplify] add tests for div/rem with bool divisor; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335509 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-25 18:27:14 +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
Sanjay Patel f4f8a442ba [InstSimplify] Add tests for missed optimizations in simplifyUnsignedRangeCheck (NFC)
These are the baseline tests for the functional change in D47922.

Patch by Li Jia He!

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335128 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-20 14:03:13 +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 6dc64e29f8 [NFC][InstSimplify] Add tests for add nuw %x, -1 -> -1 fold.
%ret = add nuw i8 %x, C
From 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.

https://rise4fun.com/Alive/sldC
Was mentioned in D47428 review.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334236 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-07 21:19:50 +00:00
Roman Lebedev 04cb3cb239 [NFC][InstSimplify] One more negative test for shl nuw C, %x -> C fold.
Follow-up for rL334200, rL334206.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334235 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-07 21:19:45 +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
Roman Lebedev afa7b32d8f [NFC][InstSimplify] Add more tests for shl nuw C, %x -> C fold.
Follow-up for rL334200.
For these, KnownBits will be needed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334206 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-07 16:18:26 +00:00
Roman Lebedev 837cf88a09 [NFC][InstSimplify] Add tests for shl nuw C, %x -> C fold.
%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.

https://rise4fun.com/Alive/WMk
Was mentioned in D47428 review.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334200 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-07 14:18:38 +00:00
Sanjay Patel 71b0bb58eb [InstCombine] move misplaced test file and regenerate checks; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333039 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-22 23:15:56 +00:00
Sanjay Patel 42ebf193bc [InstCombine] choose 1 form of abs and nabs as canonical
We already do this for min/max (see the blob above the diff), 
so we should do the same for abs/nabs.
A sign-bit check (<s 0) is used as a predicate for other IR 
transforms and it's likely the best for codegen.

This might solve the motivating cases for D47037 and D47041, 
but I think those patches still make sense. We can't guarantee 
this canonicalization if the icmp has more than one use.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332819 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-20 14:23:23 +00:00
Shiva Chen a8a13bc662 [DebugInfo] Add DILabel metadata and intrinsic llvm.dbg.label.
In order to set breakpoints on labels and list source code around
labels, we need collect debug information for labels, i.e., label
name, the function label belong, line number in the file, and the
address label located. In order to keep these information in LLVM
IR and to allow backend to generate debug information correctly.
We create a new kind of metadata for labels, DILabel. The format
of DILabel is

!DILabel(scope: !1, name: "foo", file: !2, line: 3)

We hope to keep debug information as much as possible even the
code is optimized. So, we create a new kind of intrinsic for label
metadata to avoid the metadata is eliminated with basic block.
The intrinsic will keep existing if we keep it from optimized out.
The format of the intrinsic is

llvm.dbg.label(metadata !1)

It has only one argument, that is the DILabel metadata. The
intrinsic will follow the label immediately. Backend could get the
label metadata through the intrinsic's parameter.

We also create DIBuilder API for labels to be used by Frontend.
Frontend could use createLabel() to allocate DILabel objects, and use
insertLabel() to insert llvm.dbg.label intrinsic in LLVM IR.

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

Patch by Hsiangkai Wang.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331841 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-09 02:40:45 +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 03c56176d2 [InstSimplify, InstCombine] add vector tests with undef elts; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330543 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-22 14:19:37 +00:00
Sanjay Patel ce3569799c [InstSimplify] move tests for shifts; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330516 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-21 16:58:00 +00:00
Sanjay Patel 7138e5f726 [InstSimplify] move/add/regenerate checks for tests; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330515 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-21 16:23:47 +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 1241873ba4 [InstSimplify, InstCombine] add/update tests with FP +0.0 vector with undef; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@328455 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-25 17:48:20 +00:00
Sanjay Patel ff51e42075 [InstSimplify] regenerate checks, move tests; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@328327 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-23 15:31:31 +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
Sanjay Patel b1c52c6fce [InstSimplify] add NaN constant diversity; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327743 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-16 20:55:55 +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
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 353be84b74 [InstSimplify] add tests with NaN operand for fp binops; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327631 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-15 14:48:39 +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 e4c28b17af [InstSimplify] add tests for frem and vectors with undef; NFC
These should all be folded. The vector tests need to have
m_AnyZero updated to ignore undef elements, but we need to
be careful not to return the existing value in that case
and unintentionally propagate undef.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327585 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-14 22:45:58 +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 0f6b1bf2e5 [InstSimplify] add tests to show missing/broken fadd folds (PR27151, PR26958); NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327554 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-14 18:52:40 +00:00
Sanjay Patel a38a41d83f [InstSimplify] regenerate checks; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327553 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-14 18:49:57 +00:00
Roman Lebedev 6f801c6c33 [InstSimplify] [NFC] cast-unsigned-icmp-cmp-0.ll - don't run instcombine
As disscussed in post-commit review of D44421, there is simply
no reason to run instcombine on this testcase.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327541 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-14 17:59:12 +00:00
Roman Lebedev f446c68a19 [InstSimplify] [NFC] Add tests for peeking through unsigned FP casts for sign compares (PR36682)
Summary:
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

Looking at the IR pattern in question, as per [[ https://github.com/rutgers-apl/alive-nj | alive-nj ]], for all the type combinations i checked
(input: `i16`, `i32`, `i64`; intermediate: `half`/`i16`, `float`/`i32`, `double`/`i64`)
for the following `icmp` comparisons the `uitofp`+`bitcast`+`icmp` can be evaluated to a boolean:
* `slt 0`
* `sgt -1`
I did not check vectors, but i'm guessing it's the same there.
{F5889242}

Thus all these cases are in the testcase (along with the vector variant with additional `undef` element in the middle).
There are no negative patterns here (unless alive-nj lied/is broken), all of these should be optimized.

Reviewers: spatel, majnemer, efriedma, arsenm

Reviewed By: spatel

Subscribers: wdng, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327535 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-14 17:31:08 +00:00
Sanjay Patel ff9e3f175e [PatternMatch] enhance m_NaN() to ignore undef elements in vectors
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327339 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-12 22:18:47 +00:00
Sanjay Patel a71d86999e [InstSimplify] add fcmp tests for constant NaN vector with undef elt; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327335 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-12 21:44:17 +00:00
Sanjay Patel f4eb10a0cb [PatternMatch, InstSimplify] allow undef elements when matching vector -0.0
This is the FP equivalent of D42818. Use it for the few cases in InstSimplify 
with -0.0 folds (that's the only current use of m_NegZero()).

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327307 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-12 18:17:01 +00:00
Sanjay Patel 538055ab89 [InstSimplify] add test for m_NegZero with undef elt; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327287 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-12 15:47:32 +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 fc21165c23 [ConstantFold] fp_binop AnyConstant, undef --> NaN
With the updated LangRef ( D44216 / rL327138 ) in place, we can proceed with more constant folding.

I'm intentionally taking the conservative path here: no matter what the constant or the FMF, we can 
always fold to NaN. This is because the undef operand can be chosen as NaN, and in our simplified 
default FP env, nothing else happens - NaN just propagates to the result. If we find some way/need 
to propagate undef instead, that can be added subsequently.

The tests show that we always choose the same quiet NaN constant (0x7FF8000000000000 in IR text). 
There were suggestions to improve that with a 'NaN' string token or not always print a 64-bit hex 
value, but those are independent changes. We might also consider setting/propagating the payload of 
NaN constants as an enhancement.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327208 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-10 15:56:25 +00:00
Sanjay Patel 815d73b1d6 [InstSimplify] fix FP infinite hex constant values in tests; NFC
Really should improve this...


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327144 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-09 16:14:02 +00:00
Sanjay Patel b70e54f12d [ConstantFold] fp_binop undef, undef --> undef
These are uncontroversial and independent of a proposed LangRef edits (D44216).

I tried to fix tests that would fold away:
rL327004
rL327028
rL327030
rL327034

I'm not sure if the Reassociate tests are meaningless yet, but they probably will be 
as we add more folds, so if anyone has suggestions or wants to fix those, please do.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327058 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-08 20:42:49 +00:00
Sanjay Patel 772c9bccc0 [InstSimplify] add more tests for FP undef; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327012 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-08 15:39:39 +00:00
Sanjay Patel e725355805 [InstSimplify] add tests for FP with undef operand; NFC
Are any of these correct?


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@326241 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-27 20:17:18 +00:00
Craig Topper 3c6e03477e [ValueTracking] Teach cannotBeOrderedLessThanZeroImpl to look through ExtractElement.
This is similar to what's done in computeKnownBits and computeSignBits. Don't do anything fancy just collect information valid for any element.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@326237 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-27 19:53:45 +00:00