[PATCH] D18830: [llvm] GVN.cpp: Do not swap when both LHS and RHS are arguments.
Aditya Kumar via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 28 06:07:28 PDT 2016
hiraditya added a comment.
So to generate examples where there are redundant swaps, I used this patch.
- a/llvm/lib/Transforms/Scalar/GVN.cpp
+++ b/llvm/lib/Transforms/Scalar/GVN.cpp
@@ -1892,8 +1892,13 @@ bool GVN::propagateEquality(Value *LHS, Value *RHS, const BasicBlockEdge &Root,
continue;
// Prefer a constant on the right-hand side, or an Argument if no constants.
- if (isa<Constant>(LHS) || (isa<Argument>(LHS) && !isa<Constant>(RHS)))
+ if (isa<Constant>(LHS)
+ || (isa<Argument>(LHS) && !isa<Constant>(RHS))){
std::swap(LHS, RHS);
+ if (isa<Argument>(LHS) && isa<Argument>(RHS))
+ llvm_unreachable("testcase: swapped once");
+ }
+
Following 7 test cases triggered with this patch:
-
./bin/opt < llvm/test/Transforms/GVN/2008-07-02-Unreachable.ll -basicaa -gvn -S | grep "ret i8 [%]tmp3"
-
./bin/opt < llvm/test/Transforms/GVN/2007-07-26-InterlockingLoops.ll -basicaa -gvn -S
-
./bin/opt < llvm/test/Transforms/GVN/local-pre.ll -gvn -enable-pre -S
-
./bin/opt < llvm/test/Transforms/GVN/condprop.ll -basicaa -gvn -S
-
./bin/opt < llvm/test/Transforms/GVN/rle-semidominated.ll -basicaa -gvn -S
-
./bin/opt < llvm/test/Transforms/GVN/rle.ll -default-data-layout="E-p:32:32:32-p1:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-n32" -basicaa -gvn -S -die
-
./bin/opt < llvm/test/Transforms/GVN/rle-nonlocal.ll -basicaa -gvn -S
Repository:
rL LLVM
http://reviews.llvm.org/D18830
More information about the llvm-commits
mailing list