[LLVMbugs] [Bug 12985] New: Reassociate drops NSW/NUW flags

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue May 29 14:04:32 PDT 2012


             Bug #: 12985
           Summary: Reassociate drops NSW/NUW flags
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: atrick at apple.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 8657
  --> http://llvm.org/bugs/attachment.cgi?id=8657

The Reassociate pass unnecessarily drops NSW/NUW flags during canonicalization.
If we really want to drop the flags, we should probably do it after indvars
where we eliminate sign/zero extension.

I noticed three situations where Reassociation drops flags in a single test

1. shl nsw x, c => mul x, 2**c
2. sub nsw x, y => add x, (sub 0, y)
3. add nsw (add nsw x, c1), c2 ; where c1 and c2 have opposite signs.

Attached unit tests:

rtest.ll does some legitimate reassociation in order to fold constants
(exhibits case #3).

rtest2.ll has an additional use of %sub, so doesn't do any actual reassociation
or folding, and is closer to the real test case, but it still drops flags

rtest2.ll would probably be easier to fix (no case #3), but it would be nice to
handle rtest.ll too. It would be a nice property to preserve the flags if
possible regardless of the number of uses

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list