[PATCH] D42103: [LSR] Don't force bases of foldable formulae to the final type.

Bevin Hansson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 29 00:45:26 PST 2018


ebevhan added a comment.

In https://reviews.llvm.org/D42103#989687, @qcolombet wrote:

> Out-of-curiosity do you actually see codegen differences with that patch?


The only difference in the test case is that the base and scale registers on the memory operation are swapped.

In our downstream target we see fairly large differences because our pointers and integers go in different registers, so it's inefficient to do a GEP like this where the base and scale are 'swapped'.



================
Comment at: lib/Transforms/Scalar/LoopStrengthReduce.cpp:4996
           isAMCompletelyFolded(TTI, LU, F)) {
-        Value *FullV = Rewriter.expandCodeFor(SE.getAddExpr(Ops), Ty);
+        Value *FullV = Rewriter.expandCodeFor(SE.getAddExpr(Ops), nullptr);
         Ops.clear();
----------------
qcolombet wrote:
> I don't think this is what we want, FullV is supposed to have the same type as F.
> 
> That said, I would have expected your test case to have been recognized by the check line 4948.
> 
> Could you check why this is not happening?
In the test case in this patch (and it's probably the same for the local test case I found this in originally), the check on 4948 does trigger. Ty is i64 and OpTy is i8*. Since the effective SCEV type for both of these is i64, Ty is set to i8* and the base (which is originally an integer) is converted into a pointer when it's expanded.


https://reviews.llvm.org/D42103





More information about the llvm-commits mailing list