[PATCH] D99027: [InstCombine] Whitelist non-refining folds in SimplifyWithOpReplaced
Juneyoung Lee via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 20 20:01:58 PDT 2021
aqjune accepted this revision.
aqjune added a comment.
This revision is now accepted and ready to land.
It is impressive that leaving the few patterns was enough to cover all existing unit tests.
If more patterns are needed, we can factor out the non-refined foldings from SimplifyXXInst as a static function and call it here.
Since ConstantFoldInstOperands can return a refined value as well, I gave a shot and disabled the folding if AllowRefinement = false.
However, it resulted in many unit test failures (implying that it will prevent a lot of optimizations). I couldn't write an input that involves constant folding but results in miscompilation either; so I think it is fine.
LGTM, but it would be good if someone else can double-check the diffs as well.
================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:4042
return ConstantFoldInstOperands(I, ConstOps, Q.DL, Q.TLI);
}
----------------
This might make the result more refined as well, is it? ConstantFoldBinaryInstruction may fold undef/poison into a well-defined value.
I think it is better to leave a comment here saying the issue.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D99027/new/
https://reviews.llvm.org/D99027
More information about the llvm-commits
mailing list