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 47658 - LoopReroll incorrectly reorders memory instrs when there is overlap
Summary: LoopReroll incorrectly reorders memory instrs when there is overlap
Status: NEW
Alias: None
Product: libraries
Classification: Unclassified
Component: Scalar Optimizations (show other bugs)
Version: trunk
Hardware: PC All
: P normal
Assignee: Unassigned LLVM Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-09-27 03:35 PDT by Kevin Jacobus de Vos
Modified: 2020-09-27 04:12 PDT (History)
8 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin Jacobus de Vos 2020-09-27 03:35:23 PDT
Test: Transforms/LoopReroll/basic.ll
Function: pointer_bitcast_baseinst
Reason: Memory mismatch

Example: https://godbolt.org/z/5c8YK1
Ordering of loads and stores with memory offsets:

source -  load 876, load  892, store 892, store 900, ... 
target -  load 876, store 892, load  892, store 900, ...

Since there is overlap between the memory positions of the second load and first store in source then the swapped ordering of these instructions in target is incorrect. 
This optimization should not be performed in case of such a memory overlap.

A detailed and complete Alive report with single iteration loop unroll on this test can be seen here: https://pastebin.com/pQsf61wb
Comment 1 Nuno Lopes 2020-09-27 04:12:52 PDT
Here's a manually unrolled report from Alive2: https://alive2.llvm.org/ce/z/tmuXZ_