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

Yiran Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 2 10:17:43 PDT 2023


yiranwang added a comment.
Herald added subscribers: wangpc, StephenFan.
Herald added a project: All.

This change is problematic, as something like  
if (x >= '0' && x <= '9')
before this change is "if (x - '0‘ <u 10)", and now it becomes "if (245 <u x - '9')".
The later one is more expensive, as the ZExt followed by ADD(of type i32) is not removable, say, if the ISA does not have native i8-ADD instruction. While the former form is just OK, and the ZExt is removable.
So at least, if the type does not have native addition instruction, we should not do this. Or maybe, just don't do this in general, as no cannonicalization in that sense is possible.


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