Recognize umin/umax/smin/smax intrinsics and convert them to the already existing SCEV nodes of the same name.
In the future we'll want SCEVExpander to also produce the intrinsics, but we're not there yet...
Differential D87160
[SCEV] Recognize min/max intrinsics nikic on Sep 4 2020, 1:12 PM. Authored by
Details Recognize umin/umax/smin/smax intrinsics and convert them to the already existing SCEV nodes of the same name. In the future we'll want SCEVExpander to also produce the intrinsics, but we're not there yet...
Diff Detail
Unit Tests
Event TimelineComment Actions Two afterthoughts:
---------------------------------------- define i32 @src(i32 %x, i1 %y) { %0: %r = abs i32 %x, %y ret i32 %r } => define i32 @tgt(i32 %x, i1 %y) { %0: %x_frozen = freeze i32 %x %t0 = sub i32 0, %x_frozen %r = smax i32 %x_frozen, %t0 ret i32 %r } Transformation seems to be correct! ---------------------------------------- define i32 @src(i32 %x) { %0: %r = abs i32 %x, 1 ret i32 %r } => define i32 @tgt(i32 %x) { %0: %x_frozen = freeze i32 %x %t0 = sub nsw i32 0, %x_frozen %r = smax i32 %x_frozen, %t0 ret i32 %r } Transformation seems to be correct! Comment Actions Yes, that's right. This will get resolved once we start canonicalizing to intrinsics, and until then a lot of the min/max handling is undef-unsafe anyway.
Would you like to have that included in this patch or separately? I don't believe that SCEV currently recognizes abs in select form, so this one might need additional SCEVExpander support at the same time (to at least expand it into a reasonable select). There's also some other intrinsics that could be handled, e.g. usub.sat(a, b) is umax(a, b) - b. Comment Actions Separate patch is fine i think.
Maybe, but i don't anticipate such need.
|