This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Fold Select with binary op - non-commutative opcodes
ClosedPublic

Authored by xbolva00 on Aug 2 2018, 8:12 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

xbolva00 created this revision.Aug 2 2018, 8:12 AM
xbolva00 updated this revision to Diff 158766.Aug 2 2018, 8:17 AM
xbolva00 added inline comments.
lib/Transforms/InstCombine/InstCombineSelect.cpp
87 ↗(On Diff #158765)

I would like to simplify it. But not sure what is prefered here. So kindly asking for advice :)

xbolva00 edited the summary of this revision. (Show Details)Aug 2 2018, 8:21 AM

Let's handle this one step at a time. Please remove the FP changes. Let's make this patch only about handling the non-commutative integer binops.

Also, we should have tests for 'ne' for the non-commutative ops. Please add those as a preliminary commit if they're not already here. And add test for udiv/sdiv?

test/Transforms/InstCombine/select-binop-icmp.ll
179 ↗(On Diff #158766)

This is not correct:
https://rise4fun.com/Alive/E5Y

460–463 ↗(On Diff #158766)

This should have been transformed. Similarly, for the other opcodes - the matching is reversed.

xbolva00 updated this revision to Diff 160062.Aug 9 2018, 11:31 PM
  • Added/fixed/updated tests (ok now?)
  • Removed FP opcodes support (will be done as follow up work)
xbolva00 marked 2 inline comments as done.Aug 9 2018, 11:31 PM
  • Added/fixed/updated tests (ok now?)

There aren't any positive tests for 'ne' predicates with the non-commutative opcodes?
Please at least a couple of those. You can commit all of the test changes ahead of this patch.

You should be able to adjust 2 lines of code to allow non-commutative ops after:
rL339439

xbolva00 updated this revision to Diff 160113.Aug 10 2018, 8:31 AM

You should be able to adjust 2 lines of code to allow non-commutative ops after:
rL339439

Ok, I will rebase it.

xbolva00 updated this revision to Diff 160119.Aug 10 2018, 9:00 AM
  • Rebased/updated
xbolva00 retitled this revision from [InstCombine] Fold Select with binary op - FP/non-commutative opcodes to [InstCombine] Fold Select with binary op - non-commutative opcodes.Aug 10 2018, 9:10 AM
  • Rebased/updated

Please rebase/update tests again. I had to revert rL339439 because it had a bug exposed by rearranging the predicates for this fold. I added/adjusted tests for that at rL339453, so should be fixed with rL339469.

xbolva00 updated this revision to Diff 160234.Aug 11 2018, 1:10 AM
  • Updated
xbolva00 marked an inline comment as done.Aug 11 2018, 1:10 AM
spatel accepted this revision.Aug 12 2018, 8:07 AM

LGTM

This revision is now accepted and ready to land.Aug 12 2018, 8:07 AM
This revision was automatically updated to reflect the committed changes.