This is an archive of the discontinued LLVM Phabricator instance.

[JumpThreading] Change a dyn_cast that is already protected by an isa check to a static cast. Combine the with another static cast. NFC
ClosedPublic

Authored by craig.topper on May 4 2017, 11:42 AM.

Details

Summary

I'm looking at possibly making some changes near this code. While doing that I noticed that there was a dyn_cast that was already protected by an earlier isa check. And once we do that we can hoist the cast used in the other if block and only do the cast once.

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.May 4 2017, 11:42 AM
efriedma added inline comments.May 4 2017, 12:56 PM
lib/Transforms/Scalar/JumpThreading.cpp
583 ↗(On Diff #97855)

"Cmp->getType()->isIntegerTy()" is always true, so you could just make this "if (Constant *CmpConst = dyn_cast<Constant>(Cmp->getOperand(1)))".

Doesn't isIntegerTy omit vector of integers which would be valid for cmp type?

efriedma accepted this revision.May 4 2017, 1:25 PM

Oh, oops, you're right. Could you change it to check isVectorTy() instead, to make that more obvious?

Otherwise LGTM.

This revision is now accepted and ready to land.May 4 2017, 1:25 PM
This revision was automatically updated to reflect the committed changes.