1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00
llvm-mirror/lib/Transforms
Zhongduo Lin 39b859fb9b [IndVarSimplify] Extend previous special case for load use instruction to any narrow type loop variant to avoid extra trunc instruction
Summary:
The widenIVUse avoids generating trunc by evaluating the use as AddRec, this
will not work when:
   1) SCEV traces back to an instruction inside the loop that SCEV can not
expand, eg. add %indvar, (load %addr)
   2) SCEV finds a loop variant, eg. add %indvar, %loopvariant

While SCEV fails to avoid trunc, we can still try to use instruction
combining approach to prove trunc is not required. This can be further
extended with other instruction combining checks, but for now we handle the
following case (sub can be "add" and "mul", "nsw + sext" can be "nus + zext")
```
Src:
  %c = sub nsw %b, %indvar
  %d = sext %c to i64
Dst:
  %indvar.ext1 = sext %indvar to i64
  %m = sext %b to i64
  %d = sub nsw i64 %m, %indvar.ext1
```
Therefore, as long as the result of add/sub/mul is extended to wide type with
right extension and overflow wrap combination, no
trunc is required regardless of how %b is generated. This pattern is common
when calculating address in 64 bit architecture.

Note that this patch reuse almost all the code from D49151 by @az:
https://reviews.llvm.org/D49151

It extends it by providing proof of why trunc is unnecessary in more general case,
it should also resolve some of the concerns from the following discussion with @reames.

http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20180910/585945.html

Reviewers: sanjoy, efriedma, sebpop, reames, az, javed.absar, amehsan

Reviewed By: az, amehsan

Subscribers: hiraditya, llvm-commits, amehsan, reames, az

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D73059
2020-03-05 16:27:59 -05:00
..
AggressiveInstCombine [ConstantFolding] Always return something from ConstantFoldConstant 2020-03-04 18:24:47 +01:00
CFGuard Add missing newlines at EOF; NFC 2020-02-12 15:57:25 +00:00
Coroutines [Coroutines] Optimized coroutine elision based on reachability 2020-03-05 14:43:50 +08:00
Hello
InstCombine [InstCombine] Don't explicitly invoke const folding in shift combine 2020-03-04 18:33:00 +01:00
Instrumentation Reland: [Coverage] Revise format to reduce binary size 2020-02-28 18:12:04 -08:00
IPO [ConstantFolding] Always return something from ConstantFoldConstant 2020-03-04 18:24:47 +01:00
ObjCARC [ObjC][ARC] Don't move a retain call living outside a loop into the loop 2020-02-25 13:00:10 -08:00
Scalar [IndVarSimplify] Extend previous special case for load use instruction to any narrow type loop variant to avoid extra trunc instruction 2020-03-05 16:27:59 -05:00
Utils [PGO][PGSO] Use IsColdXNthPercentile for sample PGO. 2020-03-05 09:54:54 -08:00
Vectorize [VPlan] Use consecutive numbers to print VPValues instead of addresses. 2020-03-05 14:55:15 +00:00
CMakeLists.txt Add Windows Control Flow Guard checks (/guard:cf). 2019-10-28 15:19:39 +00:00
LLVMBuild.txt Add Windows Control Flow Guard checks (/guard:cf). 2019-10-28 15:19:39 +00:00