[llvm] [clang] [Instcombine] use zext's nneg flag for icmp folding (PR #70845)

Nikita Popov via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 11 00:48:42 PST 2023


================
@@ -247,6 +355,19 @@ define i1 @sext_zext_uge_op0_wide(i16 %x, i8 %y) {
   ret i1 %c
 }
 
+
+define i1 @sext_zext_nneg_uge_op0_wide(i16 %x, i8 %y) {
+; CHECK-LABEL: @sext_zext_nneg_uge_op0_wide(
+; CHECK-NEXT:    [[TMP1:%.*]] = sext i8 [[Y:%.*]] to i16
+; CHECK-NEXT:    [[C:%.*]] = icmp ule i16 [[TMP1]], [[X:%.*]]
+; CHECK-NEXT:    ret i1 [[C]]
+;
+  %a = sext i16 %x to i32
+  %b = zext nneg i8 %y to i32
+  %c = icmp uge i32 %a, %b
+  ret i1 %c
+}
+
 define i1 @zext_sext_sgt_known_nonneg(i8 %x, i8 %y) {
 ; CHECK-LABEL: @zext_sext_sgt_known_nonneg(
----------------
nikic wrote:

Yeah, these tests are largely redundant now. We could delete them, but I think it's also okay to keep them to show the combination of nneg inference and this fold.

https://github.com/llvm/llvm-project/pull/70845


More information about the cfe-commits mailing list