OSDN Git Service

[DAGCombiner] Improve zextload optimization.
authorGeoff Berry <gberry@codeaurora.org>
Wed, 11 Nov 2015 19:42:52 +0000 (19:42 +0000)
committerGeoff Berry <gberry@codeaurora.org>
Wed, 11 Nov 2015 19:42:52 +0000 (19:42 +0000)
commite2eaa9712db78fe0a0ddbd10c5322c45c54af9a8
treea8574a31481df625c559240dd6599e6ffb582f9a
parent8ad0ca8af4bd9c81333344a8510a60cabdf2406d
[DAGCombiner] Improve zextload optimization.

Summary:
Don't fold
  (zext (and (load x), cst)) -> (and (zextload x), (zext cst))
if
  (and (load x) cst)
will match as a zextload already and has additional users.

For example, the following IR:

  %load = load i32, i32* %ptr, align 8
  %load16 = and i32 %load, 65535
  %load64 = zext i32 %load16 to i64
  store i32 %load16, i32* %dst1, align 4
  store i64 %load64, i64* %dst2, align 8

used to produce the following aarch64 code:

ldr w8, [x0]
and w9, w8, #0xffff
and x8, x8, #0xffff
str w9, [x1]
str x8, [x2]

but with this change produces the following aarch64 code:

ldrh w8, [x0]
str w8, [x1]
str x8, [x2]

Reviewers: resistor, mcrosier

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D14340

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252789 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
test/CodeGen/AArch64/free-zext.ll