This is an archive of the discontinued LLVM Phabricator instance.

Allow ScalarEvolution to catch more min/max cases
ClosedPublic

Authored by jdoerfert on Feb 2 2015, 5:17 AM.

Details

Summary
For the test case attached different types are used in the ICmpInst
and SelectInst that represent the min/max expressions. However, if the
ICmpInst type is smaller a comparison with the sign/zero extended
operands would have yielded the same result. This situation might arise after
the instruction combination pass was applied.

Diff Detail

Event Timeline

jdoerfert updated this revision to Diff 19144.Feb 2 2015, 5:17 AM
jdoerfert retitled this revision from to Allow ScalarEvolution to catch more min/max cases.
jdoerfert updated this object.
jdoerfert added reviewers: sunfish, atrick, bkramer.
jdoerfert added a subscriber: Unknown Object (MLST).

The logic here looks pretty obviously correct. I am confused about the
whitespace though. This looks right:

+ if (getTypeSizeInBits(LHS->getType()) <=
+ getTypeSizeInBits(U->getType())) {

but these do not:

+ if (getTypeSizeInBits(LHS->getType()) <=
+ getTypeSizeInBits(U->getType()) &&

...

+ if (getTypeSizeInBits(LHS->getType()) <=
+ getTypeSizeInBits(U->getType()) &&

Consider clang-format'ing and then commit.

Johannes Doerfert wrote:

Hi sunfish, atrick, bkramer,

For the test case attached different types are used in the ICmpInst
and SelectInst that represent the min/max expressions. However, if the
ICmpInst type is smaller a comparison with the sign/zero extended
operands would have yielded the same result. This situation might arise after
the instruction combination pass was applied.

http://reviews.llvm.org/D7338

Files:

lib/Analysis/ScalarEvolution.cpp
test/Analysis/ScalarEvolution/min-max-exprs.ll

EMAIL PREFERENCES

http://reviews.llvm.org/settings/panel/emailpreferences/

llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

atrick accepted this revision.Feb 6 2015, 5:05 PM
atrick edited edge metadata.

LGTM

This revision is now accepted and ready to land.Feb 6 2015, 5:05 PM

Commited in r228571.

jdoerfert closed this revision.Feb 11 2015, 6:35 AM