[PATCH] Hoist load based on alias analysis

hfinkel at anl.gov hfinkel at anl.gov
Sun Oct 26 07:59:00 PDT 2014


As a general note, please upload patches with full context, see: http://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface

REPOSITORY
  rL LLVM

================
Comment at: lib/Transforms/Scalar/MergedLoadStoreMotion.cpp:270
@@ +269,3 @@
+    if (AA->isMustAlias(LocLoad0, LocLoad1) &&
+        Load0->getType() == Load0->getType() &&
+        !isLoadHoistBarrierInRange(BB1->front(), *Load1, Load1) &&
----------------
This is not really sufficient, we also need to check the other possible Load flags (atomic properties, volatile, alignment). This is easy to do:
  Load0->isSameOperationAs(Load1)

(it looks like this is all guarded on a check that the load isSimple, so we know the atomic properties and volatile are a non-issue, but the alignment still needs checking ).

Also, this line has a typo, (Load0->getType() == Load0->getType()) is always true.

================
Comment at: test/Transforms/InstMerge/ld_hoist1.ll:19
@@ +18,3 @@
+; CHECK getelementptr inbounds i32* %in
+; CHECK load
+for.body:                                         ; preds = %for.body.lr.ph, %for.inc
----------------
I think these checks could be more specific. I think you can explicitly match the first gep and load and then match the second get (picking up the name by regex) but specifying the form, and then making sure the second load uses that address.

================
Comment at: test/Transforms/InstMerge/ld_hoist1.ll:64
@@ +63,3 @@
+
+attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
+
----------------
Remove unnecessary attributes.

================
Comment at: test/Transforms/InstMerge/ld_hoist1.ll:68
@@ +67,2 @@
+
+!0 = metadata !{metadata !"clang version 3.6.0 (219111)"}
----------------
Remove unnecessary metadata.

http://reviews.llvm.org/D5991






More information about the llvm-commits mailing list