This is an archive of the discontinued LLVM Phabricator instance.

fixing return value of performScalarPRE() ignored issue
AbandonedPublic

Authored by vincentqiuuu on Nov 20 2015, 5:45 PM.

Details

Summary

The return value of performScalarPRE() at its call site in function bool GVN::processNonLocalLoad(LoadInst *LI) is not taken into account. This patch fixes the issue.

Diff Detail

Event Timeline

vincentqiuuu retitled this revision from to fixing return value of performScalarPRE() ignored issue.
vincentqiuuu updated this object.
vincentqiuuu added reviewers: mehdi_amini, reames.
vincentqiuuu added a subscriber: llvm-commits.
mehdi_amini edited edge metadata.Dec 11 2015, 2:35 PM

Thanks for the patch, there is a broken test in the validation with this patch: test/Transforms/GVN/pre-gep-load.ll

Can you have a look?

Note: It is very likely that the test just need to be updated, but you may want to be sure why.

Okay I'll take a look.

Le vendredi 11 décembre 2015, Mehdi AMINI <mehdi.amini@apple.com> a écrit :

joker.eph added a comment.

Note: It is very likely that the test just need to be updated, but you may
want to be sure why.

http://reviews.llvm.org/D14899

vincentqiuuu abandoned this revision.Jan 12 2016, 11:24 AM

After studying the test case that failed and GVN.cpp, I found that int the function processNonLocalLoad(LoadInst *LI), not taking the return value of performScalarPRE(I) into account is actually correct. It's not a bug because performScalarPRE(I) is just a step of analyzing when the first operand of the LoadInst is a GEP, which means the LoadInst follows a GEP. performScalarPRE(I) can return true (the GEP is thus eliminated) whereas the LoadInst is not eliminated and thus processNonLocalLoad(LoadInst *LI) should return false.

I was about to tell you what you just discovered :)

THe real issue here is that we are inconsistent in what the return values
of these functions mean.
processNonLocalLoad is not returning whether it changed, but whether it
deleted the load.
processLoad in turn is also returning whether it deleted the load.

However, processInstruction then uses this to determine if the function has
changed ...

If you want to make these functions return whether anything changed, i'm
not opposed, but you have to carefully go through the logic separate the
two things it uses the return values for ;)