[PATCH] D55735: [InstSimplify] Simplify saturating add/sub + icmp

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 17 06:44:21 PST 2018


nikic marked 2 inline comments as done.
nikic added inline comments.


================
Comment at: lib/Analysis/InstructionSimplify.cpp:2681-2682
+    } else if (match(II.getOperand(1), m_APInt(C))) {
+      if (C->isNegative()) {
+        // ssub.sat(x, -C) produces [SINT_MIN - (-C), SINT_MAX]:
+        Lower = APInt::getSignedMinValue(Width) - *C;
----------------
spatel wrote:
> What happens if C is the signed min value here?
> 
> ```
> define i1 @ssub_icmp_op1_is_min_val(i8 %a) {
>   %b = call i8 @llvm.ssub.sat.i8(i8 %a, i8 -128)
>   %c = icmp sle i8 %b, -118
>   ret i1 %c
> }
> 
> ```
This will fold to `ret i1 false`. The computed range here is `[0, SINT_MAX]`. The last test is intended to check this case.


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

https://reviews.llvm.org/D55735





More information about the llvm-commits mailing list