[PATCH] D113366: [InstCombine] Canonicalize range test idiom

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 7 10:06:42 PST 2021


nikic added inline comments.


================
Comment at: llvm/test/Transforms/InstCombine/2006-12-15-Range-Test.ll:58
 ; CHECK-NEXT:    [[TMP16]] = load i32, i32* [[TMP15]], align 4
-; CHECK-NEXT:    [[TMP16_OFF:%.*]] = add i32 [[TMP16]], 31
-; CHECK-NEXT:    [[TMP0:%.*]] = icmp ugt i32 [[TMP16_OFF]], 62
-; CHECK-NEXT:    br i1 [[TMP0]], label [[BB27_EXITSTUB:%.*]], label [[COND_NEXT23_EXITSTUB:%.*]]
+; CHECK-NEXT:    [[TMP0:%.*]] = add i32 [[TMP16]], -32
+; CHECK-NEXT:    [[TMP1:%.*]] = icmp ult i32 [[TMP0]], -63
----------------
xbolva00 wrote:
> Maybe prefer ugt? To keep positive numbers. (Common cases).
Using ugt will not prefer positive numbers in general, it depends on the tested range. I did check that variant, and the impact is about the same, just for different test cases.

We would have to canonicalize to ugt/ult based on some heuristic involving the specific constants required, which seems a bit unusual for InstCombine.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113366/new/

https://reviews.llvm.org/D113366



More information about the llvm-commits mailing list