summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/InstCombine/zext-bool-add-sub.ll
Commit message (Collapse)AuthorAgeFilesLines
* [InstCombine] Invert `add A, sext(B) --> sub A, zext(B)` canonicalization ↵Roman Lebedev2019-12-051-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (to `sub A, zext B -> add A, sext B`) Summary: D68408 proposes to greatly improve our negation sinking abilities. But in current canonicalization, we produce `sub A, zext(B)`, which we will consider non-canonical and try to sink that negation, undoing the existing canonicalization. So unless we explicitly stop producing previous canonicalization, we will have two conflicting folds, and will end up endlessly looping. This inverts canonicalization, and adds back the obvious fold that we'd miss: * `sub [nsw] Op0, sext/zext (bool Y) -> add [nsw] Op0, zext/sext (bool Y)` https://rise4fun.com/Alive/xx4 * `sext(bool) + C -> bool ? C - 1 : C` https://rise4fun.com/Alive/fBl It is obvious that `@ossfuzz_9880()` / `@lshr_out_of_range()`/`@ashr_out_of_range()` (oss-fuzz 4871) are no longer folded as much, though those aren't really worrying. Reviewers: spatel, efriedma, t.p.northover, hfinkel Reviewed By: spatel Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D71064
* Revert "Temporarily Revert "Add basic loop fusion pass.""Eric Christopher2019-04-171-0/+404
| | | | | | | | The reversion apparently deleted the test/Transforms directory. Will be re-reverting again. llvm-svn: 358552
* Temporarily Revert "Add basic loop fusion pass."Eric Christopher2019-04-171-404/+0
| | | | | | | | As it's causing some bot failures (and per request from kbarton). This reverts commit r358543/ab70da07286e618016e78247e4a24fcb84077fda. llvm-svn: 358546
* [InstCombine] canonicalize add/sub with boolSanjay Patel2019-02-241-8/+8
| | | | | | | | | | | | | | | | | | | | | | | add A, sext(B) --> sub A, zext(B) We have to choose 1 of these forms, so I'm opting for the zext because that's easier for value tracking. The backend should be prepared for this change after: D57401 rL353433 This is also a preliminary step towards reducing the amount of bit hackery that we do in IR to optimize icmp/select. That should be waiting to happen at a later optimization stage. The seeming regression in the fuzzer test was discussed in: D58359 We were only managing that fold in instcombine by luck, and other passes should be able to deal with that better anyway. llvm-svn: 354748
* [InstCombine] add tests for ext-of-bool + add/sub; NFCSanjay Patel2019-01-291-0/+87
| | | | | | | | | | | | | | | We should choose one of these as canonical: %z = zext i1 %cmp to i32 %r = sub i32 %x, %z => %s = sext i1 %cmp to i32 %r = add i32 %x, %s The test comments assume that the zext form is better, but we can adjust that if we decide to go the other way. llvm-svn: 352515
* [InstCombine] improve sub with bool foldsSanjay Patel2018-06-031-5/+3
| | | | | | | | There's a patchwork of existing transforms trying to handle these cases, but as seen in the changed test, we weren't catching them all. llvm-svn: 333845
* [InstCombine] move/add tests for sub with bool op; NFCSanjay Patel2018-05-221-44/+240
| | | | llvm-svn: 333012
* [InstCombine] canonicalize constant-minus-boolean to select-of-constantsSanjay Patel2017-12-061-6/+3
| | | | | | | | | | | | | | | | | | | | | | | This restores the half of: https://reviews.llvm.org/rL75531 that was reverted at: https://reviews.llvm.org/rL159230 For the x86 case mentioned there, we now produce: leal 1(%rdi), %eax subl %esi, %eax We have target hooks to invert this in DAGCombiner (and x86 is enabled) with: https://reviews.llvm.org/rL296977 https://reviews.llvm.org/rL311731 AArch64 and possibly other targets would probably benefit from enabling those hooks too. See PR30327: https://bugs.llvm.org/show_bug.cgi?id=30327#c2 Differential Revision: https://reviews.llvm.org/D40612 llvm-svn: 319964
* [InstCombine] add tests for select-of-constants; NFCSanjay Patel2017-11-291-0/+33
| | | | | | | | | These are variants of a test that was originally added in: https://reviews.llvm.org/rL75531 ...but removed with: https://reviews.llvm.org/rL159230 llvm-svn: 319327
* [InstCombine] allow zext(bool) + C --> select bool, C+1, C for vector typesSanjay Patel2017-10-131-4/+2
| | | | | | | The backend should be prepared for this transform after: https://reviews.llvm.org/rL311731 llvm-svn: 315701
* [InstCombine] add tests for boolean extend + add; NFCSanjay Patel2017-10-131-0/+32
| | | | llvm-svn: 315681
* add more tests for PR30273Sanjay Patel2016-09-121-2/+32
| | | | llvm-svn: 281270
* [InstCombine] add test for PR30327Sanjay Patel2016-09-121-0/+14
| | | | llvm-svn: 281248
* [InstCombine] regenerate checksSanjay Patel2016-09-121-4/+7
| | | | llvm-svn: 281247
* Add back commit r210029.Rafael Espindola2014-06-021-1/+1
| | | | | | | | The code was actually correct. Sorry for the confusion. I have expanded the comment saying why the analysis is valid to avoid me misunderstaning it again in the future. llvm-svn: 210052
* Revert "Add the nsw flag when we detect that an add will not signed overflow."Rafael Espindola2014-06-021-1/+1
| | | | | | | | | This reverts commit r210029. It was not correctly handling cases where LHS and RHS had multiple but different sign bits. llvm-svn: 210048
* Add the nsw flag when we detect that an add will not signed overflow.Rafael Espindola2014-06-021-1/+1
| | | | | | | We already had a function for checking this, we were just using it only in specialized cases. llvm-svn: 210029
* Update Transforms tests to use CHECK-LABEL for easier debugging. No ↵Stephen Lin2013-07-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 186268
* Transform (sub 0, (zext bool to A)) to (sext bool to A) andPaul Redmond2013-01-211-2/+2
| | | | | | | | | (sub 0, (sext bool to A)) to (zext bool to A). Patch by Muhammad Ahmad Reviewed by Duncan Sands llvm-svn: 173093
* Remove a instcombine transform that (no longer?) makes sense:Evan Cheng2012-06-261-26/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | // C - zext(bool) -> bool ? C - 1 : C if (ZExtInst *ZI = dyn_cast<ZExtInst>(Op1)) if (ZI->getSrcTy()->isIntegerTy(1)) return SelectInst::Create(ZI->getOperand(0), SubOne(C), C); This ends up forming sext i1 instructions that codegen to terrible code. e.g. int blah(_Bool x, _Bool y) { return (x - y) + 1; } => movzbl %dil, %eax movzbl %sil, %ecx shll $31, %ecx sarl $31, %ecx leal 1(%rax,%rcx), %eax ret Without the rule, llvm now generates: movzbl %sil, %ecx movzbl %dil, %eax incl %eax subl %ecx, %eax ret It also helps with ARM (and pretty much any target that doesn't have a sext i1 :-). The transformation was done as part of Eli's r75531. He has given the ok to remove it. rdar://11748024 llvm-svn: 159230
* Use opt -S instead of piping bitcode output through llvm-dis.Dan Gohman2009-09-081-1/+1
| | | | llvm-svn: 81257
* Change these tests to feed the assembly files to opt directly, insteadDan Gohman2009-09-081-1/+1
| | | | | | of using llvm-as, now that opt supports this. llvm-svn: 81226
* Fix bug in run-line.Eli Friedman2009-07-131-3/+1
| | | | llvm-svn: 75534
* Canonicalize boolean +/- a constant to a select.Eli Friedman2009-07-131-0/+31
(I think it's reasonably clear that we want to have a canonical form for constructs like this; if anyone thinks that a select is not the best canonical form, please tell me.) llvm-svn: 75531
OpenPOWER on IntegriCloud