diff options
author | Alon Zakai (kripken) <alonzakai@gmail.com> | 2017-02-11 21:55:14 -0800 |
---|---|---|
committer | Alon Zakai (kripken) <alonzakai@gmail.com> | 2017-02-16 22:45:37 -0800 |
commit | c06b3762a09e95443fd0f159b2675209db1dbb29 (patch) | |
tree | fcdeda6f567e35a11582e5879746c20910499388 /src/passes/OptimizeInstructions.cpp | |
parent | 2553266cf716df3f03d5d057887ed660c12f4fb6 (diff) | |
download | binaryen-c06b3762a09e95443fd0f159b2675209db1dbb29.tar.gz binaryen-c06b3762a09e95443fd0f159b2675209db1dbb29.tar.bz2 binaryen-c06b3762a09e95443fd0f159b2675209db1dbb29.zip |
optimize out a sign-ext into a store of the same size
Diffstat (limited to 'src/passes/OptimizeInstructions.cpp')
-rw-r--r-- | src/passes/OptimizeInstructions.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/passes/OptimizeInstructions.cpp b/src/passes/OptimizeInstructions.cpp index 1c549cab6..cf5ad982e 100644 --- a/src/passes/OptimizeInstructions.cpp +++ b/src/passes/OptimizeInstructions.cpp @@ -525,6 +525,12 @@ struct OptimizeInstructions : public WalkerPass<PostWalker<OptimizeInstructions, } } } + } else if (auto* ext = getSignExt(binary)) { + // if sign extending the exact bit size we store, we can skip the extension + // if extending something bigger, then we just alter bits we don't save anyhow + if (getSignExtBits(binary) >= store->bytes * 8) { + store->value = ext; + } } } else if (auto* unary = store->value->dynCast<Unary>()) { if (unary->op == WrapInt64) { |