summaryrefslogtreecommitdiff
path: root/lib/Transforms/InstCombine/InstCombine.h
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2012-10-23 08:28:26 +0000
committerDuncan Sands <baldrick@free.fr>2012-10-23 08:28:26 +0000
commitbbc7016c60bfe319f4d3bbc525547596e85c9aad (patch)
tree5b5208761de421c1c9653c61850c0816a333c3e8 /lib/Transforms/InstCombine/InstCombine.h
parentc1f7ae15bb970b347ddeb80d4474f7e7f2099a60 (diff)
downloadllvm-bbc7016c60bfe319f4d3bbc525547596e85c9aad.tar.gz
llvm-bbc7016c60bfe319f4d3bbc525547596e85c9aad.tar.bz2
llvm-bbc7016c60bfe319f4d3bbc525547596e85c9aad.tar.xz
Transform code like this
%V = mul i64 %N, 4 %t = getelementptr i8* bitcast (i32* %arr to i8*), i32 %V into %t1 = getelementptr i32* %arr, i32 %N %t = bitcast i32* %t1 to i8* incorporating the multiplication into the getelementptr. This happens all the time in dragonegg, for example for int foo(int *A, int N) { return A[N]; } because gcc turns this into byte pointer arithmetic before it hits the plugin: D.1590_2 = (long unsigned int) N_1(D); D.1591_3 = D.1590_2 * 4; D.1592_5 = A_4(D) + D.1591_3; D.1589_6 = *D.1592_5; return D.1589_6; The D.1592_5 line is a POINTER_PLUS_EXPR, which is turned into a getelementptr on a bitcast of A_4 to i8*, so this becomes exactly the kind of IR that the transform fires on. An analogous transform (with no testcases!) already existed for bitcasts of arrays, so I rewrote it to share code with this one. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166474 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/InstCombine/InstCombine.h')
-rw-r--r--lib/Transforms/InstCombine/InstCombine.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/Transforms/InstCombine/InstCombine.h b/lib/Transforms/InstCombine/InstCombine.h
index 41017c5287..7467eca7ab 100644
--- a/lib/Transforms/InstCombine/InstCombine.h
+++ b/lib/Transforms/InstCombine/InstCombine.h
@@ -367,6 +367,10 @@ private:
Value *EvaluateInDifferentType(Value *V, Type *Ty, bool isSigned);
+
+ /// Descale - Return a value X such that Val = X * Scale, or null if none. If
+ /// the multiplication is known not to overflow then NoSignedWrap is set.
+ Value *Descale(Value *Val, APInt Scale, bool &NoSignedWrap);
};