[PATCH] SCEV incorrectly marks certain expressions as nsw

Andrew Trick atrick at apple.com
Mon Feb 16 23:35:22 PST 2015

The function's precondition no longer holds after one of your other fixes. It's good that you noticed that.

In another one of your fixes it looks like you added this check:

  if (PreAR && PreAR->getNoWrapFlags(SCEV::FlagNSW) &&

Instead of

  if (PreAR && AR->getNoWrapFlags(SCEV::FlagNSW) &&

I think the later check, which is what you have in this patch, preserves the original optimization (which unfortunately has no unit tests because it only affects LSR).

You could add an assert and avoid calling this when we don't have AR<nsw>. I'm not sure it could have any effect on optimization. At any rate, the fix you have in this patch actually seems more clear, as long as the comments aren't misleading.

...canonicalizing sext within SCEV is a really horrible business. Sorry!



More information about the llvm-commits mailing list