This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Do not fold scalar ops over select with vector condition.
ClosedPublic

Authored by fhahn on Sep 7 2018, 6:09 AM.

Details

Diff Detail

Repository
rL LLVM

Event Timeline

fhahn created this revision.Sep 7 2018, 6:09 AM
spatel accepted this revision.Sep 7 2018, 7:04 AM

LGTM - see inline for some minor bits.

lib/Transforms/InstCombine/InstCombineSelect.cpp
365 ↗(On Diff #164396)

I found this comment confusing. The select operands themselves are vectors, but the operands of those operands must also be vectors. This can only be a problem with GEPs? If that's correct, let's state that in the comment.

test/Transforms/InstCombine/select-gep.ll
141 ↗(On Diff #164396)

We could reduce this a bit I think:

define <2 x i64*> @test5(i64* %gep1, i64* %gep2, <2 x i1> %cc) {
  %gep3 = getelementptr i64, i64* %gep1, <2 x i64> undef
  %gep4 = getelementptr i64, i64* %gep2, <2 x i64> undef
  %select = select <2 x i1> %cc, <2 x i64*> %gep3, <2 x i64*> %gep4
  ret <2 x i64*> %select
}
This revision is now accepted and ready to land.Sep 7 2018, 7:04 AM
fhahn updated this revision to Diff 164417.Sep 7 2018, 7:28 AM

Adjusted comment and simplified test case.

fhahn added inline comments.Sep 7 2018, 7:29 AM
lib/Transforms/InstCombine/InstCombineSelect.cpp
365 ↗(On Diff #164396)

I tried to make it more explicit, what do you think? I *think* it only can happen for getlementptr currently, but there might be other cases ,e.g. if the code around here becomes more powerful)

test/Transforms/InstCombine/select-gep.ll
141 ↗(On Diff #164396)

Thanks! I also replaced the undef operand.

spatel added inline comments.Sep 7 2018, 7:35 AM
lib/Transforms/InstCombine/InstCombineSelect.cpp
365 ↗(On Diff #164396)

Works for me - thanks!

fhahn added a comment.Sep 7 2018, 7:41 AM

Thank you very much for having a look so quickly!

This revision was automatically updated to reflect the committed changes.