[PATCH] [IC] Turn non-null MD on pointer loads to range MD on integer loads.
Philip Reames
listmail at philipreames.com
Wed Feb 18 10:33:43 PST 2015
================
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.
----------------
For consistency, I'd prefer to see this as:
else if (NewTy->isIntegerTy()) {
auto *ITy = cast<IntegerType>(NewTy);
================
Comment at: lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp:343
@@ +342,3 @@
+ auto *ITy = dyn_cast<IntegerType>(NewTy);
+ if (!ITy) break;
+ Metadata *Range[] = {
----------------
Meta comment: This does assume that null is integer value 0. I think that's in practice a safe assumption.
================
Comment at: lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp:345
@@ +344,3 @@
+ Metadata *Range[] = {
+ ConstantAsMetadata::get(IC.Builder->getIntN(ITy->getBitWidth(), 1)),
+ ConstantAsMetadata::get(IC.Builder->getIntN(ITy->getBitWidth(),
----------------
I think you'd be better off using MDBuilder::createRange here.
================
Comment at: test/Transforms/InstCombine/loadstore-metadata.ll:88
@@ -88,3 +87,3 @@
; CHECK-LABEL: @test_load_cast_combine_nonnull(
-; CHECK: %[[V:.*]] = load i64* %{{.*}}
+; CHECK: %[[V:.*]] = load i64* %{{.*}}, !range
; CHECK-NOT: !nonnull
----------------
You need more specific tests here. in particular, what does the metadata look like?. Other cases to consider: store(p, load(p)), bitcast(load(p), IntTy),
http://reviews.llvm.org/D7621
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the llvm-commits
mailing list