[PATCH] D23268: [EarlyCSE] Teach about CSE'ing over invariant.start intrinsics

Anna Thomas via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 9 11:32:53 PDT 2016


anna added inline comments.

================
Comment at: test/Transforms/EarlyCSE/invariant.start.ll:50
@@ +49,3 @@
+  store i8 50, i8* %P
+  %i = call {}* @llvm.invariant.start.p0i8(i64 1, i8* %P)
+  store i8 60, i8* %P
----------------
sanjoy wrote:
> Why do you need to prevent DSE here?  As written, the program is undefined (since we're changing an invariant location).
> 
> The only problematic optimization around invariant_(start|end) that I can come up with is stores floating into the invariant region.  DSE seems fine, even in case like:
> 
> ```
> *ptr = 100
> k = invariant_start(ptr)
> ;; BODY
> invariant_end(k, ptr)
> *ptr = 500
> ```
> 
> If `BODY` contains a read from `ptr` then we won't DSE the first store, but if not, it looks like it is fine to DSE it.
So, DSE can take place since anyway the program would be undefined with stores following invariant.start. Also, with invariant_start/end in place, DSE will not take place since invariant_end is still read-write.

I think with the CSE optimization, stores cannot float *into* the invariant region. So, I'll remove the lastStore to nullptr and keep the DSE tests.



https://reviews.llvm.org/D23268





More information about the llvm-commits mailing list