InstCombine: Canonicalize (gep i8* X, -(ptrtoint Y)) to (sub (ptrtoint X), (ptrtoint Y))
authorBenjamin Kramer <benny.kra@googlemail.com>
Fri, 20 Sep 2013 14:38:44 +0000 (14:38 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Fri, 20 Sep 2013 14:38:44 +0000 (14:38 +0000)
commit4c332fa5a5a650cd779935d78b505f84cef4db69
tree5214ed46cdcf9af5d90465acdd5109568517810d
parent86075251108afff556420effa670e7d07b203555
InstCombine: Canonicalize (gep i8* X, -(ptrtoint Y)) to (sub (ptrtoint X), (ptrtoint Y))

The GEP pattern is what SCEV expander emits for "ugly geps". The latter is what
you get for pointer subtraction in C code. The rest of instcombine already
knows how to deal with that so just canonicalize on that.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191090 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstructionCombining.cpp
test/Transforms/InstCombine/getelementptr.ll