[PATCH] D12016: [SeparateConstOffsetFromGEP] sext(a)+sext(b) => sext(a+b) when a+b can't sign-overflow.

Jingyue Wu via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 13 14:58:56 PDT 2015


jingyue added inline comments.

================
Comment at: lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp:1101
@@ +1100,3 @@
+      match(I, m_NSWSub(m_Value(LHS), m_Value(RHS)))) {
+    if (isKnownNotFullPoison(I)) {
+      const SCEV *Key =
----------------
broune wrote:
> I think that you also need to check that I has a NSW or NUW flag.
> 
> I wonder if it would be faster to insert all the add/sub dominators with such a flag and then check isKnownNotFullPoison(I) only when an instruction is returned from findClosestMatchingDominator().
I did check that I has a NSW flag by using `m_NSWAdd` and `m_NSWSub`. 

It's hard to tell. In the current way, the hash table is smaller and findClosestMatchingDominator more likely returns nullptr. Though I agree it calls `isKnownNotFullPoison` more if matched SCEVs are rare. 


http://reviews.llvm.org/D12016





More information about the llvm-commits mailing list