[PATCH] D112637: [SCEVExpander] Be more conservative about poison flags when reusing instructions

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 27 12:54:05 PDT 2021


reames added a comment.

Realized after some further thought, that the entire approach here is potentially unsound.

Counter example:
%x = add nsw nuw %a, %b
call maythrow()
%y = mul nuw 32 %x, 1

Both the current code and my proposed fix would use the flags inferred from %x, to allow reuse of ^y.  In this particular case, that happens to be a valid result, but the reasoning is highly suspect.  The basic problem is that the flags on the SCEV may apply to a different operation type than the instruction.  Mapping e.g. mul to add or vice versa is not obviously correct.

I'm going to give this one a bit more thought to see if there's a better approach.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112637/new/

https://reviews.llvm.org/D112637



More information about the llvm-commits mailing list