[PATCH] D36247: [LVI] Constant-propagate a zero extension of the switch condition value through case edges

Hiroshi Yamauchi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 2 16:03:28 PDT 2017


yamauchi added a comment.

The issue with https://reviews.llvm.org/D34822 was that it is not correct to propagate the constant range of the value that's derived from the switch condition to the *default* edge.

For example,

%12 = and i64 %11, 1
switch i64 %11, label %default [

  i64 0, label %86
  i64 3, label %87

]

...

%default:

  %92 = icmp eq i64 %12, 0, !dbg !1921
  br i1 %92, label %94, label %93, !dbg !1921

It's correct to propagate that %11 != 0 and %11 != 3 to the %default edge.

But it's not correct to propagate the corresponding value of %12, that is %12 != 0 (0 & 1) and %12 != 1 (3 & 1), on the %default edge (which isn't even logically possible.)

The fix is to restrict the default-case propagation to the "Val == Condition" case only.


https://reviews.llvm.org/D36247





More information about the llvm-commits mailing list