https://llvm.org/bugs/show_bug.cgi?id=23333

            Bug ID: 23333
           Summary: Inverted conditionals not being CSEd
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

We currently fail to recognize the CSE oppurtunity in the following example in
EarlyCSE or JumpThreading.  GVN does get this case:
define i8 @earlycse(i8 addrspace(1)* %ptr) {
   %cnd = icmp eq i8 addrspace(1)* %ptr, null
   br i1 %cnd, label %null, label %not_null
null:
   %cnd2 = icmp ne i8 addrspace(1)* %ptr, null
   %res = select i1 %cnd2, i8 2, i8 1
   ret i8 %res

not_null:
   ret i8 0
}

For EarlyCSE:
When we encounter %cnd2, we could lookup it's inverse in the SimpleValue
structure and use the negation of that check.  

For JumpThreading:
We should know that %ptr == null at the compare.  We just don't appear to be
using this fact at all.

Alternatively, we could choose to canonicalize the NE to an EQ case and invert
the select.  If that approach was chosen, InstCombine might be a more
reasonable place.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to