[LLVMbugs] [Bug 20542] New: Wrong folding of xor in DAGCombiner

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Aug 5 04:07:00 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=20542

            Bug ID: 20542
           Summary: Wrong folding of xor in DAGCombiner
           Product: new-bugs
           Version: unspecified
          Hardware: Other
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: nrink at broadcom.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 12858
  --> http://llvm.org/bugs/attachment.cgi?id=12858&action=edit
Added check for argument's bit width to 'visitXOR' in DAGCombiner.

The DAGCombiner tries to fold 'xor %tmp, 1' into  '!%tmp' (read: "not %tmp").
This is valid only if the type of %tmp is i1.

Example code that triggers this problem:
  1 @g_609 = global i32 42
  2 
  3 define i32 @main() #0 {
  4 entry:
  5      %0 = load i32* @g_609, align 4
  6      %cmp = icmp slt i32 %0, 1
  7      %sub = sext i1 %cmp to i32
  8      %xor = xor i32 %sub, 1
  9      ret i32 %xor
 10 }
NOTE: The problem occurs only if the first argument of the 'xor' is a
'select_cc' node. Since X86 does not lower 'select_cc', this problem cannot be
reproduced on X86.

Suggested patch attached.

-- 
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/20140805/f5aeffc9/attachment.html>


More information about the llvm-bugs mailing list