[LLVMbugs] [Bug 23333] New: Inverted conditionals not being CSEd

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Apr 23 14:11:08 PDT 2015


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: unassignedbugs at nondot.org
          Reporter: listmail at philipreames.com
                CC: llvmbugs at cs.uiuc.edu
    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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150423/8287a98a/attachment.html>


More information about the llvm-bugs mailing list