https://bugs.llvm.org/show_bug.cgi?id=52135

            Bug ID: 52135
           Summary: [InstSimplify] fold compare of no-wrap subtract
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedb...@nondot.org
          Reporter: spatel+l...@rotateright.com
                CC: llvm-bugs@lists.llvm.org

Noticed in https://reviews.llvm.org/rGda210f5d3425 :

define i1 @test_negative_combined_sub_signed_overflow(i8 %x) {
  %y = sub nsw i8 127, %x
  %z = icmp slt i8 %y, -1
  ret i1 %z
}

This is always false.

define i1 @test_negative_combined_sub_unsigned_overflow(i64 %x) {
  %y = sub nuw i64 10, %x
  %z = icmp ult i64 %y, 11
  ret i1 %z
}

This is always true.

--------------------------------------------------------------------------

-instcombine will now handle those transforms in multiple steps, but it won't
work if the subtract has an extra use. 

This should be added to -instsimplify, so we don't have that limitation, and
the analysis can be used by other passes. 

The transforms should not be limited to "less-than" predicates. The check might
be implemented with a ConstantRange or an overflow check on constant math.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to