[llvm-dev] ScalarEvolution "add nsw" question

Sanjoy Das via llvm-dev llvm-dev at lists.llvm.org
Sun Apr 10 17:19:37 PDT 2016


Johannes Doerfert wrote:
 > Is there any plan to use e.g., post-dominance information to
 > propagate wrapping flags?

None that I'm aware of.

 > If x +nsw y post-dominates the entry block
 > [and is used in some side-effect instruction] the SCEV could be marked
 > as non-wrapping, couldn't it?

Yes, but we have to be careful to account for exceptions, infinitely
looping functions, exit(0) etc.  I.e. in

void foo() {
   use(x + y);
   exit(0);
   use(x +nsw y);
}

the nsw in the later x+y cannot be transferred to the former x+y
(assume use is a side effecting use).

 > How do you determine if the operation will
 > poison a side-effect instruction anyway?

SCEV uses llvm::isKnownNotFullPoison for this.

-- Sanjoy


More information about the llvm-dev mailing list