[PATCH] D109676: [HardwareLoops] put +1 for loop count before zero extension
Sam Parker via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 15 03:11:33 PDT 2021
samparker added inline comments.
================
Comment at: llvm/lib/Analysis/TargetTransformInfo.cpp:188
+ // as not overflow. Hareware count register will handle the count 0 case well.
+ // For example, on PowerPC, if the value in the Count Register is 0 before
+ // being decremented, it is -1 afterward.
----------------
This comment is making me uneasy... I'm don't think target specific stuff should be referenced in this generic layer. But either way, why would a count register ever have a value of -1, especially when we're expending quite some effort to test against zero in this transform?
================
Comment at: llvm/lib/CodeGen/HardwareLoops.cpp:417
// different. It means there will be instruction(s) in a block that possibly
// aren't needed. The isLoopEntryGuardedByCond is trying to avoid this issue,
// but it's doesn't appear to work in all cases.
----------------
Let's now remove this comment about isLoopEntryGuardedByCond.
================
Comment at: llvm/test/Transforms/HardwareLoops/scalar-while.ll:311
; CHECK-PHIGUARD-NEXT: entry:
; CHECK-PHIGUARD-NEXT: [[CMP4:%.*]] = icmp slt i32 [[I:%.*]], [[N:%.*]]
; CHECK-PHIGUARD-NEXT: [[TMP0:%.*]] = add i32 [[I]], 1
----------------
shchenz wrote:
> The test changes is due to `isLoopEntryGuardedByCond` can not determine that SCEV `(1 + (-1 * %N) + %i)` is at least 1 before. But now, we assume that the TripCount is at least 1 if we enter the loop. And we also check that TripCount will not overflow when we set TripCount.
These are minor regressions, but they're inline with the other previous sub-optimal cases so I think it's okay.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109676/new/
https://reviews.llvm.org/D109676
More information about the llvm-commits
mailing list