Commit Graph

32 Commits

Author SHA1 Message Date
Sanjay Patel 54b09599fc [InstSimplify] move minnum/maxnum with Inf folds from instcombine
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339396 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-09 22:20:44 +00:00
Sanjay Patel c517d08361 [InstSimplify] fold fsub+fadd with common operand
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339176 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-07 20:32:55 +00:00
Sanjay Patel a5d9c8f92a [InstSimplify] fold fadd+fsub with common operand
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339174 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-07 20:23:49 +00:00
Sanjay Patel c10f372ba1 [InstSimplify] fold fsub+fsub with common operand
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339171 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-07 20:14:27 +00:00
Sanjay Patel b651cfc711 [InstSimplify] add tests for fadd/fsub; NFC
Instcombine gets some, but not all, of these cases via
it's internal reassociation transforms. It fails in
all cases with vector types.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339168 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-07 19:49:13 +00:00
Sanjay Patel 5ab217ce42 [InstSimplify] move minnum/maxnum with common op fold from instcombine
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339144 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-07 14:36:27 +00:00
Sanjay Patel 7e35c221fb [InstSimplify] add tests for minnum/maxnum with shared op; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339142 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-07 14:13:40 +00:00
Sanjay Patel 1b7b25a023 [InstSimplify] move misplaced minnum/maxnum tests; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339141 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-07 14:12:08 +00:00
Sanjay Patel e1c9b76cd3 [InstSimplify] move minnum/maxnum with undef fold from instcombine
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338719 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-02 14:33:40 +00:00
Sanjay Patel 5ea9eaae86 [InstSimplify] move minnum/maxnum with same arg fold from instcombine
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338652 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-01 23:05:55 +00:00
Sanjay Patel 268055dd8c [InstSimplify] fold minnum/maxnum with NaN arg
This fold is repeated/misplaced in instcombine, but I'm
not sure if it's safe to remove that yet because some
other folds appear to be asserting that the transform
has occurred within instcombine itself.

This isn't the best fix for PR37776, but it probably
hides the bug with the given code example:
https://bugs.llvm.org/show_bug.cgi?id=37776

We have another test to demonstrate the more general bug.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337127 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-15 14:52:16 +00:00
Sanjay Patel 4dd709869f [InstSimplify] add tests for minnum/maxnum; NFC
This isn't the best fix for PR37776, but it probably
hides the bug with the given code example:
https://bugs.llvm.org/show_bug.cgi?id=37776

We have another test to demonstrate the more general
bug.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337126 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-15 14:46:48 +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 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
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
Sanjay Patel 6555592c60 [InstCombine, InstSimplify] add tests with undef elements in constant FP vectors; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@326148 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-26 23:23:02 +00:00
Craig Topper b3dee20a05 [ValueTracking] Teach cannotBeOrderedLessThanZeroImpl to handle vector constants.
Summary: This allows vector fabs to be removed in more cases.

Reviewers: spatel, arsenm, RKSimon

Reviewed By: spatel

Subscribers: wdng, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@326138 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-26 22:33:17 +00:00
Craig Topper 1cb6402670 [InstSimplify] Add test cases for removal of vector fabs on known positive.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@326050 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-25 06:51:52 +00:00
Craig Topper d2f46f5fc1 [InstSimplify] Remove unused parameter from test cases.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@326049 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-25 06:51:51 +00:00
Sanjay Patel 30138e8179 [InstCombine, InstSimplify] (re)move tests, regenerate checks; NFC
The InstCombine integer mul test file had tests that belong in InstSimplify 
(including fmul tests). Move things to where they belong and auto-generate
complete checks for everything.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@325037 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-13 18:22:53 +00:00
Justin Lebar 34292bd5ac [ValueTracking] Implement SignBitMustBeZero correctly for sqrt.
Summary:
Previously we assumed that the result of sqrt(x) always had 0 as its
sign bit.  But sqrt(-0) == -0.

Reviewers: hfinkel, efriedma, sanjoy

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293115 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-26 00:10:26 +00:00
Matt Arsenault 1f4353fb62 InstSimplify: Eliminate fabs on known positive
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291624 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-11 00:33:24 +00:00
Zia Ansari ea5455c788 [InstSimplify] Add "X / 1.0" to SimplifyFDivInst.
Differential Revision: https://reviews.llvm.org/D27587


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289153 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-08 23:27:40 +00:00
Sanjay Patel 328a9cb5c6 [InstSimplify] add fdiv x/1.0 test and update checks; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289098 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-08 20:23:56 +00:00
Sanjay Patel 89e202e5fa [InstSimplify] regenerate checks using a script
I didn't notice any significant changes in the actual checks here;
all of these tests already used FileCheck, so a script can batch
update them in one shot.

This commit is just to show the value of automating this process: 
We have uniform formatting as opposed to a mish-mash of check
structure that changes based on individual prefs and the current
fashion. This makes it simpler to update when we find a bug or
make an enhancement.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264457 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-25 20:12:25 +00:00
Benjamin Kramer e8af9d944e [InstSimplify] fsub 0.0, (fsub -0.0, X) ==> X is only safe if signed zeros are ignored.
Only allow fsub -0.0, (fsub -0.0, X) ==> X without nsz. PR26746.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@262212 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-29 11:12:23 +00:00
Sanjay Patel d2c64e2df9 Fix really obscure bug in CannotBeNegativeZero() (PR22688)
With a diabolically crafted test case, we could recurse
through this code and return true instead of false.

The larger engineering crime is the use of magic numbers. 
Added FIXME comments for those.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230515 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-25 18:00:15 +00:00
Stephen Lin 39f4e8d9cc Update Transforms tests to use CHECK-LABEL for easier debugging. No functionality change.
This update was done with the following bash script:

  find test/Transforms -name "*.ll" | \
  while read NAME; do
    echo "$NAME"
    if ! grep -q "^; *RUN: *llc" $NAME; then
      TEMP=`mktemp -t temp`
      cp $NAME $TEMP
      sed -n "s/^define [^@]*@\([A-Za-z0-9_]*\)(.*$/\1/p" < $NAME | \
      while read FUNC; do
        sed -i '' "s/;\(.*\)\([A-Za-z0-9_]*\):\( *\)@$FUNC\([( ]*\)\$/;\1\2-LABEL:\3@$FUNC(/g" $TEMP
      done
      mv $TEMP $NAME
    fi
  done


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186268 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-14 01:42:54 +00:00
Benjamin Kramer 8e708d30a3 Add missing colons to check lines.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179277 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-11 12:41:41 +00:00
Michael Ilseman 09ee250e72 Added a slew of SimplifyInstruction floating-point optimizations, many of which take advantage of fast-math flags. Test cases included.
fsub X, +0 ==> X
  fsub X, -0 ==> X, when we know X is not -0
  fsub +/-0.0, (fsub -0.0, X) ==> X
  fsub nsz +/-0.0, (fsub +/-0.0, X) ==> X
  fsub nnan ninf X, X ==> 0.0
  fadd nsz X, 0 ==> X
  fadd [nnan ninf] X, (fsub [nnan ninf] 0, X) ==> 0
    where nnan and ninf have to occur at least once somewhere in this expression
  fmul X, 1.0 ==> X



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169940 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-12 00:27:46 +00:00