[PATCH] [IC] Turn non-null MD on pointer loads to range MD on integer loads.
Charles Davis
cdavis5x at gmail.com
Fri Feb 20 12:15:18 PST 2015
================
Comment at: lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp:343
@@ +342,3 @@
+ auto *ITy = dyn_cast<IntegerType>(NewTy);
+ if (!ITy) break;
+ Metadata *Range[] = {
----------------
reames wrote:
> Meta comment: This does assume that null is integer value 0. I think that's in practice a safe assumption.
You know, the possibility of `null != 0` crossed my mind, but I dismissed it because like you said, in practice, on every platform we support, `null == 0`. In fact, the only example I can think of off the top of my head is segmented-memory-model x86, where `null` would be a 0 segment and an `undef` offset (i.e. doesn't matter)--and I get the feeling that nobody around here wants to support //that//. ;)
Do you want me to add a `FIXME` or some other comment here noting this?
================
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
----------------
reames wrote:
> 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),
I'm pretty sure `InstCombine` combines a store of a load from the same pointer away.
Strangely, `InstCombine` doesn't convert your second case (which really should be `ptrtoint(load(p), IntTy)`, but I digress) to `load(bitcast(p, IntTy*))`. That might be something to look into.
http://reviews.llvm.org/D7621
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the llvm-commits
mailing list