[PATCH] [IC] Turn non-null MD on pointer loads to range MD on integer loads.

Chandler Carruth chandlerc at gmail.com
Mon Feb 23 12:26:59 PST 2015


Good to commit with the MDBuilder hoisted and my question about the metadata CHECK line addressed.


================
Comment at: lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp:340
@@ -341,1 +339,3 @@
         NewLoad->setMetadata(ID, N);
+      else {
+        // If it's integral, translate it to !range metadata.
----------------
Can use continue here to avoid the else.

================
Comment at: lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp:346
@@ +345,3 @@
+                             MDBuilder(NewLoad->getContext())
+                               .createRange(APInt(ITy->getBitWidth(), 1),
+                                            ITy->getMask()));
----------------
reames wrote:
> I'd have a mild preference that the builder be pulled out into it's own statement, but we're into nits at this point.  Feel free to ignore.
Yea, it'd be good to create the MDBuilder above, outside of the loop, etc.

================
Comment at: lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp:351-353
@@ -343,5 +350,5 @@
 
     case LLVMContext::MD_range:
       // FIXME: It would be nice to propagate this in some way, but the type
       // conversions make it hard.
       break;
----------------
Do you want to handle the inverse in this patch? That would then make for a nice round-trip test that we can go from pointer -> int -> pointer and preserve non-null.

================
Comment at: test/Transforms/InstCombine/loadstore-metadata.ll:98
@@ -99,2 +97,3 @@
 
+; CHECK: ![[MD]] = !{i64 1, i64 -1}
 !0 = !{ !1, !1, i64 0 }
----------------
Does this work even if the above test case isn't the last one in the file? I wonder if we need to make the IR printing denormalize this somewhat for easier checking.

http://reviews.llvm.org/D7621

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list