LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 17452 - SCEV createNodeForPHI is too optimistic about NSW.
Summary: SCEV createNodeForPHI is too optimistic about NSW.
Status: NEW
Alias: None
Product: new-bugs
Classification: Unclassified
Component: new bugs (show other bugs)
Version: trunk
Hardware: PC All
: P normal
Assignee: Unassigned LLVM Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-02 17:06 PDT by Andrew Trick
Modified: 2013-10-02 17:06 PDT (History)
1 user (show)

See Also:
Fixed By Commit(s):


Attachments
Unit test (623 bytes, application/octet-stream)
2013-10-02 17:06 PDT, Andrew Trick
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Trick 2013-10-02 17:06:27 PDT
Created attachment 11329 [details]
Unit test

SCEV::createNodeForPhi flags an AddRec expression as NSW if the value on the backedge is flagged nsw. It disregards whether the value has the same form as the expression, or is merely a subexression as in:

        %i.0 = phi i32 [ 0, %pre ], [ %tmp3, %loop ]
        %tmp2 = add i32 %i.0, 1
        %tmp3 = add nsw i32 %tmp2, 1
        %check = icmp slt i32 %i.0, %N

A unit test is attached. It could be appended to nsw.ll.

I believe it would be sufficient to test if one of the BEValue's operands is the PHINode before propagating NSW without losing any important cases.