This is an archive of the discontinued LLVM Phabricator instance.

[InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X transforms
ClosedPublic

Authored by craig.topper on Aug 11 2020, 11:29 AM.

Details

Summary

This recommits the following patches now that D85684 has landed

1cf6f210a2e [IR] Disable select ? C : undef -> C fold in ConstantFoldSelectInstruction unless we know C isn't poison.
469da663f2d [InstSimplify] Re-enable select ?, undef, X -> X transform when X is provably not poison
122b0640fc9 [InstSimplify] Don't fold vectors of partial undef in SimplifySelectInst if the non-undef element value might produce poison
ac0af12ed2f [InstSimplify] Add test cases for opportunities to fold select ?, X, undef -> X when we can prove X isn't poison
9b1e95329af [InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X transforms

Diff Detail

Event Timeline

craig.topper created this revision.Aug 11 2020, 11:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 11 2020, 11:29 AM
craig.topper requested review of this revision.Aug 11 2020, 11:29 AM
craig.topper added inline comments.
llvm/test/Transforms/InstSimplify/select.ll
850

This test is still being simplified so I dropped the comment. I guess isGuaranteedNotToBeUndefOrPoison has been improved?

nikic added inline comments.Aug 11 2020, 11:37 AM
llvm/lib/IR/ConstantFold.cpp
804

Why does this not use isGuaranteedNotToBeUndefOrPoison?

craig.topper added inline comments.Aug 11 2020, 11:38 AM
llvm/lib/IR/ConstantFold.cpp
804

I don't think IR library can depend on the Analysis library.

nikic accepted this revision.Aug 11 2020, 1:01 PM

LGTM

clang/test/CodeGen/arm-mve-intrinsics/dup.c
246

Does the lowering for these intrinsics need to be adjusted in some way? This looks a bit odd and is possibly not what was intended with this fold gone. @dmgreen

llvm/lib/IR/ConstantFold.cpp
804

Oh, right, that makes sense. We'll probably want to extract this at some later point in time.

This revision is now accepted and ready to land.Aug 11 2020, 1:01 PM