[PATCH] D58981: CodeGenPrepare: preserve inbounds attribute when sinking GEPs

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 8 06:57:58 PST 2019


dmgreen added a comment.

This looks generally useful. Please add context



================
Comment at: llvm/lib/CodeGen/CodeGenPrepare.cpp:1954
 
+  bool InBounds = true;
+
----------------
This can perhaps go with the other variables above the enum


================
Comment at: llvm/lib/CodeGen/CodeGenPrepare.cpp:1975
+    // Conservatively reject 'inbounds' mismatches.
+    if (InBounds != other.InBounds)
+      return MultipleFields;
----------------
If one of the two is inbounds, does that not make the other inbounds? In other words, why would a mismatch in the inbounds flag matter?


================
Comment at: llvm/lib/CodeGen/CodeGenPrepare.cpp:2077
+  if (InBounds)
+    OS << "(inbounds)";
   if (BaseGV) {
----------------
I would drop the brackets, but it's only debug output so up to you.


================
Comment at: llvm/test/CodeGen/Thumb/addr-modes.ll:37
 ; Expected: GEP can be folded into LOAD.
-; CHECK: local addrmode: [2*%x]
+; CHECK: local addrmode: [(inbounds)2*%x]
 define i32 @load03(i32 %x) nounwind {
----------------
This isn't really inbounds, is it? But we don't use that info here, (we don't create a gep), so it's alright? It's a little confusing, at least


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58981/new/

https://reviews.llvm.org/D58981





More information about the llvm-commits mailing list