[PATCH] D122013: [InstCombine] Fold abs of known negative operand when source is sub

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 22 08:35:21 PDT 2022


spatel added inline comments.


================
Comment at: llvm/test/Transforms/InstCombine/abs-intrinsic.ll:461
 ; CHECK:       cond.true:
-; CHECK-NEXT:    [[SUB:%.*]] = sub nsw i32 [[X]], [[Y]]
-; CHECK-NEXT:    [[TMP0:%.*]] = call i32 @llvm.abs.i32(i32 [[SUB]], i1 true)
+; CHECK-NEXT:    [[SUB_NEG:%.*]] = sub i32 [[Y]], [[X]]
 ; CHECK-NEXT:    br label [[COND_END]]
----------------
This should have propagated the 'nsw', right?
https://alive2.llvm.org/ce/z/5q5YHb

If this is an existing problem (but might be invisible before this patch), I think it is ok to mark this with a 'TODO' comment.


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

https://reviews.llvm.org/D122013



More information about the llvm-commits mailing list